public async Task GetToggles_ReturnsAList_WithAllTheToggles_ForTheGivenApplication() { //arrange var app = Application.Create("BCC", "dev", false); app.AddFeatureToggle("TestToggle", "TestNotes", "workItemID", true); app.AddFeatureToggle("TestToggle2", "TestNotes2", "workItemID2"); await _appRepository.AddAsync(app); //act var result = await _featureToggleController.GetToggles(app.Id) as OkObjectResult; var list = result.Value as IEnumerable <FeatureToggleViewModel>; //assert list.Count().Should().Be(2); var toggle = list.FirstOrDefault(t => t.ToggleName == "TestToggle"); toggle.Notes.Should().Be("TestNotes"); toggle.CreatedDate.Should().BeCloseTo(DateTime.UtcNow, 200); toggle.UserAccepted.Should().Be(false); toggle.IsPermanent.Should().Be(true); toggle.WorkItemIdentifier.Should().Be("workItemID"); }
public void GetToggles_ReturnsAList_WithAllTheToggles_ForTheGivenApplication() { //arrange var app = new Application { AppName = "BCC", Id = 1 }; var date = DateTime.Now; var firstFeatureToggle = new FeatureToggle { Application = app, ApplicationId = app.Id, UserAccepted = true, ToggleName = "TestToggle", CreatedDate = date, Notes = "TestNote", IsPermanent = true }; var secondFeatureToggle = new FeatureToggle { Application = app, ApplicationId = app.Id, UserAccepted = false, ToggleName = "TestToggle", CreatedDate = date, Notes = "TestNote" }; _context.FeatureToggles.AddRange(firstFeatureToggle, secondFeatureToggle); _context.SaveChanges(); var controller = new FeatureTogglesController(_context); //act var result = controller.GetToggles(app.Id) as OkObjectResult; var list = result.Value as IEnumerable <FeatureToggleViewModel>; //assert list.Count().Should().Be(2); list.First().Notes.Should().Be(firstFeatureToggle.Notes); list.First().CreatedDate.Should().Be(date); list.First().ToggleName.Should().Be(firstFeatureToggle.ToggleName); list.First().UserAccepted.Should().Be(firstFeatureToggle.UserAccepted); list.First().IsPermanent.Should().Be(firstFeatureToggle.IsPermanent); }
public void GetToggles_ReturnsAList_WithAllTheToggles_AndTheStatusesOfThoseToggles_ForTheGivenApplication() { //arrange var app = new Application { AppName = "BCC", Id = 1 }; var featureToggle = new FeatureToggle { Application = app, ApplicationId = app.Id }; var env = new DeployEnvironment { Application = app, EnvName = "DEV" }; var devFeatureStatus = new FeatureToggleStatus { Id = 1, Environment = env, FeatureToggle = featureToggle, FeatureToggleId = app.Id, Enabled = true, IsDeployed = true }; var qaFeatureStatus = new FeatureToggleStatus { Id = 2, Environment = env, FeatureToggle = featureToggle, FeatureToggleId = app.Id, Enabled = false, IsDeployed = false }; _context.FeatureToggles.Add(featureToggle); _context.Applications.Add(app); _context.DeployEnvironments.Add(env); _context.FeatureToggleStatuses.AddRange(devFeatureStatus, qaFeatureStatus); _context.SaveChanges(); var controller = new FeatureTogglesController(_context); //act var result = controller.GetToggles(app.Id) as OkObjectResult; result.Should().NotBeNull(); var list = result.Value as IEnumerable <FeatureToggleViewModel>; //assert list.First().Statuses.Count.Should().Be(2); }