public async Task Tags_Update_DoesUpdate() { Random rnd = new Random(); tags tag = new tags { Name = Guid.NewGuid().ToString(), TaggingsCount = rnd.Next(1, 255) }; await tag.Create(dbContext).ConfigureAwait(false); //Act DateTime?oldUpdatedAt = tag.UpdatedAt; string oldName = tag.Name; int? oldTaggingsCount = tag.TaggingsCount; int? oldId = tag.Id; tag.Name = Guid.NewGuid().ToString(); tag.TaggingsCount = rnd.Next(1, 255); await tag.Update(dbContext).ConfigureAwait(false); List <tags> tags = dbContext.tags.AsNoTracking().ToList(); List <tag_versions> tagVersions = dbContext.tag_versions.AsNoTracking().ToList(); //Assert Assert.NotNull(tags); Assert.NotNull(tagVersions); Assert.AreEqual(1, tags.Count()); Assert.AreEqual(2, tagVersions.Count()); Assert.AreEqual(tag.CreatedAt.ToString(), tags[0].CreatedAt.ToString()); Assert.AreEqual(tag.Version, tags[0].Version); // Assert.AreEqual(tag.UpdatedAt.ToString(), tags[0].UpdatedAt.ToString()); Assert.AreEqual(tags[0].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(tag.Name, tags[0].Name); Assert.AreEqual(tag.Id, tags[0].Id); //Version 1 Old Version Assert.AreEqual(tag.CreatedAt.ToString(), tagVersions[0].CreatedAt.ToString()); Assert.AreEqual(1, tagVersions[0].Version); // Assert.AreEqual(oldUpdatedAt.ToString(), tagVersions[0].UpdatedAt.ToString()); Assert.AreEqual(tagVersions[0].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(oldName, tagVersions[0].Name); Assert.AreEqual(oldId, tagVersions[0].TagId); //Version 2 Updated Version Assert.AreEqual(tag.CreatedAt.ToString(), tagVersions[1].CreatedAt.ToString()); Assert.AreEqual(2, tagVersions[1].Version); // Assert.AreEqual(tag.UpdatedAt.ToString(), tagVersions[1].UpdatedAt.ToString()); Assert.AreEqual(tagVersions[1].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(tag.Name, tagVersions[1].Name); Assert.AreEqual(tag.Id, tagVersions[1].TagId); }
public async Task <tags> CreateTag(string name, string workflowState, int version) { tags tag = new tags(); tag.Name = name; tag.WorkflowState = workflowState; tag.Version = version; await tag.Create(dbContext).ConfigureAwait(false); // DbContext.tags.Add(tag); // await dbContext.SaveChangesAsync().ConfigureAwait(false); return(tag); }
public async Task SiteTags_Delete_DoesDelete() { // Arrange Random rnd = new Random(); sites site = new sites { Name = Guid.NewGuid().ToString(), MicrotingUid = rnd.Next(1, 255) }; await site.Create(dbContext).ConfigureAwait(false); tags tag = new tags { Name = Guid.NewGuid().ToString(), TaggingsCount = rnd.Next(1, 255) }; await tag.Create(dbContext).ConfigureAwait(false); site_tags siteTag = new site_tags { SiteId = site.Id, TagId = tag.Id }; await siteTag.Create(dbContext).ConfigureAwait(false); // Act await siteTag.Delete(dbContext).ConfigureAwait(false); List <site_tags> siteTags = dbContext.SiteTags.AsNoTracking().ToList(); List <site_tag_versions> siteTagVersions = dbContext.SiteTagVersions.AsNoTracking().ToList(); // Assert Assert.NotNull(siteTags); Assert.NotNull(siteTagVersions); Assert.AreEqual(siteTag.SiteId, siteTags[0].SiteId); Assert.AreEqual(siteTag.TagId, siteTags[0].TagId); Assert.AreEqual(siteTag.WorkflowState, Constants.WorkflowStates.Removed); Assert.AreEqual(siteTag.SiteId, siteTagVersions[0].SiteId); Assert.AreEqual(siteTag.TagId, siteTagVersions[0].TagId); Assert.AreEqual(siteTagVersions[0].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(siteTag.SiteId, siteTagVersions[1].SiteId); Assert.AreEqual(siteTag.TagId, siteTagVersions[1].TagId); Assert.AreEqual(siteTagVersions[1].WorkflowState, Constants.WorkflowStates.Removed); }
public async Task Tags_Create_DoesCreate() { //Arrange Random rnd = new Random(); tags tag = new tags { Name = Guid.NewGuid().ToString(), TaggingsCount = rnd.Next(1, 255) }; //Act await tag.Create(dbContext).ConfigureAwait(false); List <tags> tags = dbContext.tags.AsNoTracking().ToList(); List <tag_versions> tagVersions = dbContext.tag_versions.AsNoTracking().ToList(); //Assert Assert.NotNull(tags); Assert.NotNull(tagVersions); Assert.AreEqual(1, tags.Count()); Assert.AreEqual(1, tagVersions.Count()); Assert.AreEqual(tag.CreatedAt.ToString(), tags[0].CreatedAt.ToString()); Assert.AreEqual(tag.Version, tags[0].Version); // Assert.AreEqual(tag.UpdatedAt.ToString(), tags[0].UpdatedAt.ToString()); Assert.AreEqual(tags[0].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(tag.Name, tags[0].Name); Assert.AreEqual(tag.Id, tags[0].Id); //Versions Assert.AreEqual(tag.CreatedAt.ToString(), tagVersions[0].CreatedAt.ToString()); Assert.AreEqual(1, tagVersions[0].Version); // Assert.AreEqual(tag.UpdatedAt.ToString(), tagVersions[0].UpdatedAt.ToString()); Assert.AreEqual(tagVersions[0].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(tag.Name, tagVersions[0].Name); Assert.AreEqual(tag.Id, tagVersions[0].TagId); }
public async Task Taggins_Create_DoesCreate() { Random rnd = new Random(); short shortMinValue = Int16.MinValue; short shortmaxValue = Int16.MaxValue; bool randomBool = rnd.Next(0, 2) > 0; tags tag = new tags { Name = Guid.NewGuid().ToString(), TaggingsCount = rnd.Next(1, 255) }; await tag.Create(dbContext).ConfigureAwait(false); check_lists checklist = new check_lists { Color = Guid.NewGuid().ToString(), Custom = Guid.NewGuid().ToString(), Description = Guid.NewGuid().ToString(), Field1 = rnd.Next(1, 255), Field2 = rnd.Next(1, 255), Field3 = rnd.Next(1, 255), Field4 = rnd.Next(1, 255), Field5 = rnd.Next(1, 255), Field6 = rnd.Next(1, 255), Field7 = rnd.Next(1, 255), Field8 = rnd.Next(1, 255), Field9 = rnd.Next(1, 255), Field10 = rnd.Next(1, 255), Label = Guid.NewGuid().ToString(), Repeated = rnd.Next(1, 255), ApprovalEnabled = (short)rnd.Next(shortMinValue, shortmaxValue), CaseType = Guid.NewGuid().ToString(), DisplayIndex = rnd.Next(1, 255), DownloadEntities = (short)rnd.Next(shortMinValue, shortmaxValue), FastNavigation = (short)rnd.Next(shortMinValue, shortmaxValue), FolderName = Guid.NewGuid().ToString(), ManualSync = (short)rnd.Next(shortMinValue, shortmaxValue), MultiApproval = (short)rnd.Next(shortMinValue, shortmaxValue), OriginalId = Guid.NewGuid().ToString(), ParentId = rnd.Next(1, 255), ReviewEnabled = (short)rnd.Next(shortMinValue, shortmaxValue), DocxExportEnabled = randomBool, DoneButtonEnabled = (short)rnd.Next(shortMinValue, shortmaxValue), ExtraFieldsEnabled = (short)rnd.Next(shortMinValue, shortmaxValue), JasperExportEnabled = randomBool, QuickSyncEnabled = (short)rnd.Next(shortMinValue, shortmaxValue) }; await checklist.Create(dbContext).ConfigureAwait(false); taggings tagging = new taggings { Tag = tag, CheckList = checklist, TaggerId = rnd.Next(1, 255), TagId = rnd.Next(1, 255), CheckListId = checklist.Id }; //Act await tagging.Create(dbContext).ConfigureAwait(false); List <taggings> taggings = dbContext.taggings.AsNoTracking().ToList(); List <tagging_versions> taggingVersions = dbContext.tagging_versions.AsNoTracking().ToList(); //Assert Assert.NotNull(taggings); Assert.NotNull(taggingVersions); Assert.AreEqual(1, taggings.Count()); Assert.AreEqual(1, taggingVersions.Count()); Assert.AreEqual(tagging.CreatedAt.ToString(), taggings[0].CreatedAt.ToString()); Assert.AreEqual(tagging.Version, taggings[0].Version); // Assert.AreEqual(tagging.UpdatedAt.ToString(), taggings[0].UpdatedAt.ToString()); Assert.AreEqual(taggings[0].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(tagging.Id, taggings[0].Id); Assert.AreEqual(tagging.TaggerId, taggings[0].TaggerId); Assert.AreEqual(tagging.TagId, tag.Id); Assert.AreEqual(tagging.CheckListId, checklist.Id); //Version 1 Assert.AreEqual(tagging.CreatedAt.ToString(), taggingVersions[0].CreatedAt.ToString()); Assert.AreEqual(tagging.Version, taggingVersions[0].Version); // Assert.AreEqual(tagging.UpdatedAt.ToString(), taggingVersions[0].UpdatedAt.ToString()); Assert.AreEqual(taggingVersions[0].WorkflowState, Constants.WorkflowStates.Created); Assert.AreEqual(tagging.Id, taggingVersions[0].Id); Assert.AreEqual(tagging.TaggerId, taggingVersions[0].TaggerId); Assert.AreEqual(tag.Id, taggingVersions[0].TagId); Assert.AreEqual(checklist.Id, taggingVersions[0].CheckListId); }