public void ProjectionService_GetAllAsync_ReturnListOfProjecrions() { //Arrange int expectedResultCount = 1; ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.GetAllAsync(query).ConfigureAwait(false).GetAwaiter().GetResult(); var result = (List <ProjectionDomainModel>)resultAction; //Assert Assert.IsNotNull(result); Assert.AreEqual(expectedResultCount, result.Count); Assert.AreEqual(_projection.Id, result[0].Id); Assert.IsInstanceOfType(result[0], typeof(ProjectionDomainModel)); }
public void ProjectionService_GetAllAsync_ReturnsEmptyList() { //Arrange var expectedCount = 0; List <Projection> projections = new List <Projection>(); _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.GetAll()).ReturnsAsync(projections); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.GetAllAsync(query).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.AreEqual(expectedCount, resultAction.Count()); }
public void ProjectionService_GetAllAsync_ReturnNull() { //Arrange IEnumerable <Projection> projections = null; Task <IEnumerable <Projection> > responseTask = Task.FromResult(projections); _mockProjectionsRepository = new Mock <IProjectionsRepository>(); _mockProjectionsRepository.Setup(x => x.GetAll()).Returns(responseTask); ProjectionService projectionsController = new ProjectionService(_mockProjectionsRepository.Object); //Act var resultAction = projectionsController.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(resultAction); }