Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciamazere committed Feb 4, 2020
2 parents a49c736 + e15d32e commit 53faeb5
Show file tree
Hide file tree
Showing 25 changed files with 201 additions and 135 deletions.
12 changes: 9 additions & 3 deletions Moggles.Domain/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public static Application Create(string appName, string defaultEnvironmentName,
return app;
}

public void AddFeatureToggle(string toggleName, string notes, bool isPermanent = false)
public void AddFeatureToggle(string toggleName, string notes, string workItemIdentifier, bool isPermanent = false)
{
if (FeatureToggles.Exists(f => string.Compare(f.ToggleName, toggleName, StringComparison.OrdinalIgnoreCase) == 0))
{
throw new BusinessRuleValidationException("Feature toggle with the same name already exists for this application!");
}

var ft = FeatureToggle.Create(toggleName, notes, isPermanent, DeploymentEnvironments);
var ft = FeatureToggle.Create(toggleName, notes, isPermanent, DeploymentEnvironments, workItemIdentifier);
FeatureToggles.Add(ft);
}

Expand Down Expand Up @@ -117,7 +117,8 @@ public ToggleData GetFeatureToggleBasicData(Guid toggleId)
ToggleName = toggle.ToggleName,
IsPermanent = toggle.IsPermanent,
Notes = toggle.Notes,
UserAccepted = toggle.UserAccepted
UserAccepted = toggle.UserAccepted,
WorkItemIdentifier = toggle.WorkItemIdentifier
};
}

Expand All @@ -132,6 +133,11 @@ public void UpdateFeatureToggleNotes(Guid toggleId, string notes)
var toggle = FeatureToggles.Find(f => f.Id == toggleId);
toggle.SetNotes(notes);
}
public void UpdateFeaturetoggleWorkItemIdentifier(Guid toggleId, string workItemIdentifier)
{
var toggle = FeatureToggles.Find(ft => ft.Id == toggleId);
toggle.SetWorkItemIdentifier(workItemIdentifier);
}

public void FeatureAcceptedByUser(Guid toggleId)
{
Expand Down
1 change: 1 addition & 0 deletions Moggles.Domain/DTO/ToggleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public struct ToggleData
public bool UserAccepted { get; set; }
public string Notes { get; set; }
public bool IsPermanent { get; set; }
public string WorkItemIdentifier { get; set; }
}
}
13 changes: 10 additions & 3 deletions Moggles.Domain/FeatureToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public class FeatureToggle : Entity
public DateTime CreatedDate { get; set; }
public bool IsPermanent { get; set; }
public List<FeatureToggleStatus> FeatureToggleStatuses { get; set; } = new List<FeatureToggleStatus>();
public string WorkItemIdentifier { get; set; }

public static FeatureToggle Create(string name, string notes, bool isPermanent)
public static FeatureToggle Create(string name, string notes, bool isPermanent, string workItemIdentifier)
{
return new FeatureToggle
{
Expand All @@ -22,12 +23,13 @@ public static FeatureToggle Create(string name, string notes, bool isPermanent)
IsPermanent = isPermanent,
Notes = notes,
ToggleName = name,
WorkItemIdentifier = workItemIdentifier
};
}

public static FeatureToggle Create(string name, string notes, bool isPermanent, IEnumerable<DeployEnvironment> deployEnvironments)
public static FeatureToggle Create(string name, string notes, bool isPermanent, IEnumerable<DeployEnvironment> deployEnvironments, string workItemIdentifier)
{
var newToggle = Create(name, notes, isPermanent);
var newToggle = Create(name, notes, isPermanent, workItemIdentifier);

foreach (var env in deployEnvironments)
{
Expand Down Expand Up @@ -102,5 +104,10 @@ public void ChangeEnvironmentnameForFeatureToggleStatus(string oldEnvName, strin
fts.ChangeEnvironmentName(NewEnvName);
}
}

public void SetWorkItemIdentifier(string workItemIdentifier)
{
WorkItemIdentifier = workItemIdentifier;
}
}
}
8 changes: 4 additions & 4 deletions Moggles.EndToEndTests/MogglesPages/FeatureTogglesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FeatureTogglesPage
By.CssSelector("div.in > div > div > div > div > div > div > div:nth-child(1) > div > input"));

public IWebElement NotesInput => Browser.WebDriver.FindElement(
By.CssSelector("div.in > div > div > div > div > div > div > div:nth-child(2) > div > input"));
By.CssSelector("div.in > div > div > div > div > div > div > div:nth-child(3) > div > input"));

public IWebElement AddFeatureToggleButton => Browser.WebDriver.FindElement(
By.CssSelector("div.in > div > div > div.modal-body > div > div > div > div > button.btn-primary"));
Expand All @@ -48,7 +48,7 @@ public class FeatureTogglesPage
public IWebElement IsPermanentCheckbox =>
Browser.WebDriver.FindElement(
By.CssSelector(
"body > div:nth-child(1) > div> div > div > div > div.in > div > div > div> div> div > div:nth-child(9) > div > div> div > div > input[type=checkbox]"));
"body > div:nth-child(1) > div> div > div > div > div.in > div > div > div> div> div > div:nth-child(10) > div > div> div > div > input[type=checkbox]"));

public IWebElement DevEnvironmentCheckbox =>
Browser.WebDriver.FindElement(
Expand All @@ -68,7 +68,7 @@ public class FeatureTogglesPage
public IWebElement IsAcceptedByUserCheckbox =>
Browser.WebDriver.FindElement(
By.CssSelector(
"body > div:nth-child(1) > div> div > div > div > div> div > div > div> div > div:nth-child(10) > div > div> div > div > input[type=checkbox]"));
"body > div:nth-child(1) > div> div > div > div > div> div > div > div> div > div:nth-child(11) > div > div> div > div > input[type=checkbox]"));

public IWebElement SaveButton =>
Browser.WebDriver.FindElement(
Expand Down Expand Up @@ -265,7 +265,7 @@ public bool CreationDateIsCorrectlyDisplayed(string newFeatureToggleName)
{
var cells = row.FindElements(By.TagName("td"));
if (!cells[1].Text.Equals(newFeatureToggleName)) continue;
var creationDateAndTime = cells[8].Text;
var creationDateAndTime = cells[9].Text;
var creationDate =
creationDateAndTime.Substring(0, creationDateAndTime.IndexOf(" ", StringComparison.Ordinal));
var formattedCreationDate = DateTime.Parse(creationDate).Date;
Expand Down
2 changes: 1 addition & 1 deletion Moggles.EndToEndTests/TestFramework/InitTestClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public void WramupTest()

}
}
}
}
Binary file modified Moggles.EndToEndTests/chromedriver.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions Moggles.UnitTests/ApplicationsTests/ApplicationsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ public async Task DeleteApp_SchedulersForAppAreDeleted()

var date = new DateTime(2099, 3, 2, 15, 45, 0);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", null);
app.AddFeatureToggle("t2", null);
app.AddFeatureToggle("t1", null, "workItemID1");
app.AddFeatureToggle("t2", null, "workItemID2");
await _appApplicationRepository.AddAsync(app);
var schedule = ToggleSchedule.Create("TestApp", "t1", new[] { "dev" }, true, date, "updatedBy", true);
await _toggleScheduleRepository.AddAsync(schedule);
Expand Down
8 changes: 4 additions & 4 deletions Moggles.UnitTests/FeatureTogglesTests/AddEnvironmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public async Task EveryExistingFeatureToggle_IsMarkedAs_Off_ForTheNewEnvironment
{
//arrange
var app = Application.Create("TestApp", "DEV", false);
app.AddFeatureToggle("t1", string.Empty);
app.AddFeatureToggle("t2", string.Empty);
app.AddFeatureToggle("t1", string.Empty, "workItemId1");
app.AddFeatureToggle("t2", string.Empty, "workItemId2");
await _appRepository.AddAsync(app);

var newEnvironment = new AddEnvironmentModel { ApplicationId = app.Id, EnvName = "QA" };
Expand All @@ -108,8 +108,8 @@ public async Task EveryExistingFeatureToggle_IsMarkedAs_On_ForTheNewEnvironment_
//arrange
var app = Application.Create("TestApp", "DEV", false);
var newEnvironment = new AddEnvironmentModel { ApplicationId = app.Id, EnvName = "QA", DefaultToggleValue = true };
app.AddFeatureToggle("t1", string.Empty);
app.AddFeatureToggle("t2", string.Empty);
app.AddFeatureToggle("t1", string.Empty, "workItemId1");
app.AddFeatureToggle("t2", string.Empty, "workItemId2");

await _appRepository.AddAsync(app);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task ReturnBadRequestResult_WhenFeatureAlreadyExists()
{
//arrange
var app = Application.Create("bcc", "dev", false);
app.AddFeatureToggle("TestToggle", string.Empty);
app.AddFeatureToggle("TestToggle", string.Empty, "workItemId1");

var newFeatureToggle = new AddFeatureToggleModel { ApplicationId = app.Id, FeatureToggleName = "TestToggle" };

Expand Down Expand Up @@ -83,7 +83,8 @@ public async Task FeatureToggleIsCreated()
//arrange
var app = Application.Create("tst", "dev", false);
await _appRepository.AddAsync(app);
var newFeatureToggle = new AddFeatureToggleModel { ApplicationId = app.Id, FeatureToggleName = "TestToggle" };
var newFeatureToggle = new AddFeatureToggleModel { ApplicationId = app.Id, FeatureToggleName = "TestToggle", WorkItemIdentifier = "1234" };


//act
var result = await _featureToggleController.AddFeatureToggle(newFeatureToggle);
Expand All @@ -93,6 +94,7 @@ public async Task FeatureToggleIsCreated()
var toggle = (await _appRepository.FindByIdAsync(app.Id)).FeatureToggles.FirstOrDefault();
toggle.Should().NotBeNull();
toggle.ToggleName.Should().Be("TestToggle");
toggle.WorkItemIdentifier.Should().Be("1234");
}

[TestMethod]
Expand Down
14 changes: 7 additions & 7 deletions Moggles.UnitTests/FeatureTogglesTests/DeleteEnvironmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public async Task EnvironmentIsDeleted_FeatureToggleStatusForThatEnvironmentIsDe
{
//arrange
var app = Application.Create("TestApp", "TestEnv", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t2", "");
app.AddFeatureToggle("t3", "");
app.AddFeatureToggle("t1", "", "workItemId1");
app.AddFeatureToggle("t2", "", "workItemId2");
app.AddFeatureToggle("t3", "", "workItemId3");
await _appRepository.AddAsync(app);


Expand All @@ -68,9 +68,9 @@ public async Task EnvironmentIsDeleted_FeatureTogglesAreNotDeleted()
{
//arrange
var app = Application.Create("TestApp", "TestEnv", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t2", "");
app.AddFeatureToggle("t3", "");
app.AddFeatureToggle("t1", "", "workItemId1");
app.AddFeatureToggle("t2", "", "workItemId2");
app.AddFeatureToggle("t3", "", "workItemId3");
await _appRepository.AddAsync(app);

var environmentToRemove = new DeleteEnvironmentModel
Expand Down Expand Up @@ -116,7 +116,7 @@ public async Task WhenEnvironmentIsDeleted_RemoveAllSchedulersForEnvironment()
var date = new DateTime(2099, 3, 2, 15, 45, 0);
var app = Application.Create("tst", "DEV", false);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", null);
app.AddFeatureToggle("t1", null, "workItemId1");
var toggle = app.FeatureToggles.Single();
await _appRepository.AddAsync(app);
await _toggleSchedulerConstroller.ScheduleToggles(new ScheduleTogglesModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public async Task GetToggles_ReturnsAList_WithAllTheToggles_ForTheGivenApplicati
{
//arrange
var app = Application.Create("BCC", "dev", false);
app.AddFeatureToggle("TestToggle", "TestNotes", true);
app.AddFeatureToggle("TestToggle2", "TestNotes2");
app.AddFeatureToggle("TestToggle", "TestNotes", "workItemID", true);
app.AddFeatureToggle("TestToggle2", "TestNotes2", "workItemID2");

await _appRepository.AddAsync(app);

Expand All @@ -50,6 +50,8 @@ public async Task GetToggles_ReturnsAList_WithAllTheToggles_ForTheGivenApplicati
toggle.CreatedDate.Should().BeCloseTo(DateTime.UtcNow, 200);
toggle.UserAccepted.Should().Be(false);
toggle.IsPermanent.Should().Be(true);
toggle.WorkItemIdentifier.Should().Be("workItemID");

}

[TestMethod]
Expand All @@ -58,7 +60,7 @@ public async Task GetToggles_ReturnsAList_WithAllTheToggles_AndTheStatusesOfThos
//arrange
var app = Application.Create("tst", "DEV", false);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t1", "", "workItemId1");
var toggle = app.FeatureToggles.Single();
app.SetToggle(toggle.Id, "DEV", true, "username");
app.SetToggle(toggle.Id, "QA", true, "username");
Expand Down Expand Up @@ -145,7 +147,7 @@ public async Task GetApplicationFeatureToggles_ReturnsFeatureToggleState_ForTheG
//arrange
var app = Application.Create("TestApp", "DEV", false);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t1", "", "workItemId1");
var toggle = app.FeatureToggles.FirstOrDefault(f => f.ToggleName == "t1");
app.SetToggle(toggle.Id, "DEV", true, "username");
app.SetToggle(toggle.Id, "QA", false, "username");
Expand All @@ -168,7 +170,7 @@ public async Task GetApplicationFeatureToggleValue_ReturnsTheStatus_OfTheGivenFe
//arrange
var app = Application.Create("TestApp", "DEV", false);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t1", "", "workItemId1");
var toggle = app.FeatureToggles.FirstOrDefault(f => f.ToggleName == "t1");
app.SetToggle(toggle.Id, "DEV", false, "username");
app.SetToggle(toggle.Id, "QA", true, "username");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task RemoveFeatureToggle_FeatureToggleIsDeleted()
{
//arrange
var app = Application.Create("TestApp", "DEV", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t1", "", "workItemId1");
var theToggle = app.FeatureToggles.Single();
await _appRepository.AddAsync(app);

Expand All @@ -60,7 +60,7 @@ public async Task RemoveFeatureToggle_SchedulersAreDeleted()
var date = new DateTime(2099, 3, 2, 15, 45, 0);
var app = Application.Create("tst", "DEV", false);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", null);
app.AddFeatureToggle("t1", null, "workItemId1");
var toggle = app.FeatureToggles.Single();
await _appRepository.AddAsync(app);
await _toggleSchedulerConstroller.ScheduleToggles(new ScheduleTogglesModel
Expand Down
12 changes: 6 additions & 6 deletions Moggles.UnitTests/FeatureTogglesTests/UpdateEnvironmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public async Task WhenEnvironmentIsModified_EnvironmentNameForFeatureToggleStatu
//arrange
var app = Application.Create("TestApp", "DEV", true);
await _appRepository.AddAsync(app);
app.AddFeatureToggle("t1", string.Empty);
app.AddFeatureToggle("t2", string.Empty);
app.AddFeatureToggle("t1", string.Empty, "workItemId1");
app.AddFeatureToggle("t2", string.Empty, "workItemId2");
var t1 = app.FeatureToggles.ToList().FirstOrDefault(ft => ft.ToggleName == "t1");
app.SetToggle(t1.Id, "DEV", false, "bla");

Expand Down Expand Up @@ -141,8 +141,8 @@ public async Task WhenEnvironmentNameIsChanged_EnvironmentNameForToggleScheduler
//arrange
var app = Application.Create("TestApp", "DEV", true);
await _appRepository.AddAsync(app);
app.AddFeatureToggle("t1", string.Empty);
app.AddFeatureToggle("t2", string.Empty);
app.AddFeatureToggle("t1", string.Empty, "workItemId1");
app.AddFeatureToggle("t2", string.Empty, "workItemId2");
var t1 = app.FeatureToggles.ToList().FirstOrDefault(ft => ft.ToggleName == "t1");
app.SetToggle(t1.Id, "DEV", false, "bla");
var schedule = ToggleSchedule.Create("TestApp", "t1", new[] { "DEV" }, true, new DateTime(2018, 1, 1, 15, 30, 0), "updatedBy", true);
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task DefaultToggleValueChanged_NextToggleHasDefaultValue()
{
var app = Application.Create("TestApp", "DEV", true);
await _appRepository.AddAsync(app);
app.AddFeatureToggle("t1", string.Empty);
app.AddFeatureToggle("t1", string.Empty, "workItemId1");
var t1 = app.FeatureToggles.ToList().FirstOrDefault(ft => ft.ToggleName == "t1");

var updatedEnvironment = new UpdateEnvironmentModel
Expand All @@ -186,7 +186,7 @@ public async Task DefaultToggleValueChanged_NextToggleHasDefaultValue()
var result = await _featureToggleController.UpdateEnvironment(updatedEnvironment);

//assert
app.AddFeatureToggle("t2", string.Empty);
app.AddFeatureToggle("t2", string.Empty, "workItemId1");
var t2 = app.FeatureToggles.ToList().FirstOrDefault(ft => ft.ToggleName == "t2");
t1.GetFeatureToggleStatusForEnv("DEV").Enabled.Should().Be(true);
t2.GetFeatureToggleStatusForEnv("DEV").Enabled.Should().Be(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task ExistingFeatureToggleBasicDataIsUpdated()
{
//arrange
var app = Application.Create("test", "DEV", false);
app.AddFeatureToggle("TestToggle", "FirstNote");
app.AddFeatureToggle("TestToggle", "FirstNote", "WorkItemId", false);
await _appRepository.AddAsync(app);

var toggle = app.FeatureToggles.Single();
Expand All @@ -49,7 +49,8 @@ public async Task ExistingFeatureToggleBasicDataIsUpdated()
Notes = "Update",
UserAccepted = true,
Statuses = new List<FeatureToggleStatusUpdateModel>(),
IsPermanent = true
IsPermanent = true,
WorkItemIdentifier = "UpdateWorkItemId"
};

//act
Expand All @@ -61,15 +62,16 @@ public async Task ExistingFeatureToggleBasicDataIsUpdated()
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");
}

[TestMethod]
public async Task ChangingToggleName_ToExistingName_IsNotAllowed()
{
//arrange
var app = Application.Create("test", "DEV", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t2", "");
app.AddFeatureToggle("t1", "", "workItemId1");
app.AddFeatureToggle("t2", "", "workItemId1");
await _appRepository.AddAsync(app);

var toggle = app.FeatureToggles.FirstOrDefault(t => t.ToggleName == "t1");
Expand All @@ -90,7 +92,7 @@ public async Task FeatureToggleCanBeTurnedOn_ForAllExistingEnvironments()
//arrange
var app = Application.Create("test", "DEV", false);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t1", "", "workItemId1");
await _appRepository.AddAsync(app);

var toggle = app.FeatureToggles.Single();
Expand Down Expand Up @@ -131,7 +133,7 @@ public async Task FeatureToggleUpdate_ByDifferentUser_UsernameChanged()
//arrange
var app = Application.Create("test", "DEV", false);
app.AddDeployEnvironment("QA", false);
app.AddFeatureToggle("t1", "");
app.AddFeatureToggle("t1", "", "workItemId1");
await _appRepository.AddAsync(app);

var toggle = app.FeatureToggles.Single();
Expand Down
Loading

0 comments on commit 53faeb5

Please sign in to comment.