public void GetListByProjectShouldReturnAllStoriesFromProject() { // Arrange var dataList = this.GetMockDataMultiProjectList(); var projectName = "StoryMapper"; // First Project StoryRepository repository; // Act repository = new StoryRepository(dataList); var actual = repository.GetList(story => story.ProjectName == projectName); // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IEnumerable<Story>)); Assert.IsTrue(actual.Count() == 2); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); Assert.AreEqual(projectName, story.ProjectName); } // Arrange dataList = this.GetMockDataMultiProjectList(); projectName = "TestProject1"; // Second Project // Act repository = new StoryRepository(dataList); actual = repository.GetList(story => story.ProjectName == projectName); // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IEnumerable<Story>)); Assert.IsTrue(actual.Count() == 1); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); Assert.AreEqual(projectName, story.ProjectName); } // Arrange dataList = this.GetMockDataMultiProjectList(); projectName = "TestProject2"; // Third Project // Act repository = new StoryRepository(dataList); actual = repository.GetList(story => story.ProjectName == projectName); // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IEnumerable<Story>)); Assert.IsTrue(actual.Count() == 1); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); Assert.AreEqual(projectName, story.ProjectName); } }
public void DeleteStoryShouldRemoveIt() { // Arrange var dataList = this.GetMockDataList(); var repository = new StoryRepository(dataList); var expectedCount = dataList.Count() - 1; var notExpected = dataList[0]; // Act repository.Delete(notExpected); var actual = repository.GetList(); // Assert Assert.IsNotNull(actual); Assert.AreEqual(expectedCount, actual.Count()); foreach (var story in actual) { if (notExpected.ProjectName == story.ProjectName) { Assert.AreNotEqual(notExpected.Name, story.Name); } } }
public void GetListShouldReturnAllStories() { // Arrange var dataList = this.GetMockDataList(); StoryRepository repository; // Act repository = new StoryRepository(dataList); var actual = repository.GetList(); // Assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(IQueryable<Story>)); Assert.IsTrue(actual.Count() == 4); foreach (var story in actual) { Assert.IsNotNull(story.Name); Assert.IsNotNull(story.ProjectName); } }