This commit is contained in:
127
test/raven-integration/Tags/TagGroupOps.cs
Normal file
127
test/raven-integration/Tags/TagGroupOps.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace raven_integration
|
||||
{
|
||||
|
||||
public class TagGroupOps
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Test taggroup
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void GroupOpsShouldWork()
|
||||
{
|
||||
|
||||
//CREATE TAG1
|
||||
dynamic D = new JObject();
|
||||
D.name = Util.Uniquify("test-tag1-4-tag-group");
|
||||
ApiResponse R = await Util.PostAsync("Tag", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
long TestTag1Id = R.ObjectResponse["result"]["id"].Value<long>();
|
||||
|
||||
|
||||
//CREATE TAG2
|
||||
D.name = Util.Uniquify("test-tag2-4-tag-group");
|
||||
R = await Util.PostAsync("Tag", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
long TestTag2Id = R.ObjectResponse["result"]["id"].Value<long>();
|
||||
|
||||
|
||||
//CREATE TAG-GROUP
|
||||
D = new JObject();
|
||||
D.name = Util.Uniquify("test-tag-group-for-ops");
|
||||
|
||||
R = await Util.PostAsync("TagGroup", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
long TestTagGroupId = R.ObjectResponse["result"]["id"].Value<long>();
|
||||
|
||||
|
||||
//ADD TEST TAGS TO GROUP
|
||||
D = new JObject();
|
||||
D.tagId = TestTag1Id;
|
||||
D.tagGroupId= TestTagGroupId;
|
||||
R = await Util.PostAsync("TagGroupMap", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
|
||||
D.tagId = TestTag2Id;
|
||||
D.tagGroupId= TestTagGroupId;
|
||||
R = await Util.PostAsync("TagGroupMap", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//CREATE WIDGET
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify("WIDGET_TAG");
|
||||
w.created = DateTime.Now.ToString();
|
||||
w.dollarAmount = 1.11m;
|
||||
w.active = true;
|
||||
w.roles = 0;
|
||||
|
||||
R = await Util.PostAsync("Widget", await Util.GetTokenAsync("BizAdminFull"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
long widgetId = R.ObjectResponse["result"]["id"].Value<long>();
|
||||
|
||||
//CREATE TAGMAP (tag the widget)
|
||||
/*
|
||||
{
|
||||
"tagId": 0,
|
||||
"tagToObjectId": 0,
|
||||
"tagToObjectType": 0
|
||||
}
|
||||
*/
|
||||
dynamic tm = new JObject();
|
||||
tm.tagId = TestTagId;
|
||||
tm.tagToObjectId = widgetId;
|
||||
tm.tagToObjectType = 2;//widget
|
||||
|
||||
|
||||
R = await Util.PostAsync("TagMap", await Util.GetTokenAsync("BizAdminFull"), tm.ToString());
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
long tagMapId = R.ObjectResponse["result"]["id"].Value<long>();
|
||||
|
||||
//VERIFY TAGMAP
|
||||
R = await Util.GetAsync("TagMap/" + tagMapId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateDataReturnResponseOk(R);
|
||||
R.ObjectResponse["result"]["id"].Value<long>().Should().Be(tagMapId);
|
||||
|
||||
|
||||
//ATTEMPT TO DELETE TAG THAT HAS TAGMAP SHOULD FAIL with 2200 / 400
|
||||
R = await Util.DeleteAsync("Tag/" + TestTagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateViolatesReferentialIntegrityError(R);
|
||||
|
||||
//DELETE TAGMAP
|
||||
R = await Util.DeleteAsync("TagMap/" + tagMapId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(R, 204);
|
||||
|
||||
//DELETE TAG
|
||||
R = await Util.DeleteAsync("Tag/" + TestTagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(R, 204);
|
||||
|
||||
//DELETE WIDGET
|
||||
R = await Util.DeleteAsync("Widget/" + widgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(R, 204);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user