public async Task ExistingFeatureToggleBasicDataIsUpdated() { //arrange var app = Application.Create("test", "DEV", false); app.AddFeatureToggle("TestToggle", "FirstNote", "WorkItemId", false); await _appRepository.AddAsync(app); var toggle = app.FeatureToggles.Single(); toggle.AddReasonToChange("user", "reason 1", new List <string>()); var updatedValue = new FeatureToggleUpdateModel { ApplicationId = app.Id, Id = toggle.Id, FeatureToggleName = "UpdatedFeatureToggleName", Notes = "Update", UserAccepted = true, Statuses = new List <FeatureToggleStatusUpdateModel>(), IsPermanent = true, WorkItemIdentifier = "UpdateWorkItemId", ReasonToChange = new ReasontoChangeUpdateModel { Description = "reason 2", Environments = new List <string> { "DEV" } } }; //act await _featureToggleController.Update(updatedValue); //assert var savedApp = await _appRepository.FindByIdAsync(app.Id); savedApp.FeatureToggles.FirstOrDefault().ToggleName.Should().Be("UpdatedFeatureToggleName"); savedApp.FeatureToggles.FirstOrDefault().Notes.Should().Be("Update"); savedApp.FeatureToggles.FirstOrDefault().UserAccepted.Should().BeTrue(); savedApp.FeatureToggles.FirstOrDefault().IsPermanent.Should().BeTrue(); savedApp.FeatureToggles.FirstOrDefault().WorkItemIdentifier.Should().Be("UpdateWorkItemId"); savedApp.FeatureToggles.FirstOrDefault().ReasonsToChange.Count.Should().Be(2); var firstReason = savedApp.FeatureToggles.FirstOrDefault().ReasonsToChange.FirstOrDefault(); firstReason.Description.Should().Be("reason 1"); var secondReason = savedApp.FeatureToggles.FirstOrDefault().ReasonsToChange.LastOrDefault(); secondReason.Description.Should().Be("reason 2"); secondReason.Environments.Contains("DEV"); }
public void Updates_CanBeMade_ToExistingFeatureToggle() { //arrange var app = new Application { Id = 1, AppName = "TestApp" }; var existingValue = new FeatureToggle { Id = 1, Application = app, ApplicationId = app.Id, ToggleName = "TestToggle", FeatureToggleStatuses = new List <FeatureToggleStatus>(), Notes = "FirstNote", IsPermanent = false }; var updatedValue = new FeatureToggleUpdateModel { Id = 1, FeatureToggleName = "UpdatedFeatureToggleName", Notes = "Update", UserAccepted = true, Statuses = new List <FeatureToggleStatusUpdateModel>(), IsPermanent = true }; _context.FeatureToggles.Add(existingValue); _context.SaveChanges(); var controller = new FeatureTogglesController(_context); //act var result = controller.Update(updatedValue) as OkObjectResult; //assert _context.FeatureToggles.FirstOrDefault().ToggleName.Should().Be("UpdatedFeatureToggleName"); _context.FeatureToggles.FirstOrDefault().Notes.Should().Be(updatedValue.Notes); _context.FeatureToggles.FirstOrDefault().UserAccepted.Should().BeTrue(); _context.FeatureToggles.FirstOrDefault().IsPermanent.Should().BeTrue(); }