public async Task GetFigure_Throws_RepositoryThrows() { //Arrange Mock <IGeometryRepository> repositoryMock = new Mock <IGeometryRepository>(); repositoryMock.Setup(x => x.GetFigureAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())) .ThrowsAsync(new NotImplementedException()); //Act GeometryService service = GetGeometryService(repositoryMock.Object); //Assert Assert.ThrowsAsync <NotImplementedException>(() => service.FindFigureAsync(1, CancellationToken.None)); }
public async Task GetFigure_ReturnNull_NoFigureFound() { //Arrange Mock <IGeometryRepository> repositoryMock = new Mock <IGeometryRepository>(); repositoryMock.Setup(x => x.GetFigureAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())) .ReturnsAsync(null as TestEntity); //Act GeometryService service = GetGeometryService(repositoryMock.Object); //Assert var result = await service.FindFigureAsync(1, CancellationToken.None); Assert.AreEqual(null, result); }
public async Task GetFigure_Success() { //Arrange var guid = Guid.NewGuid(); Mock <IGeometryRepository> repositoryMock = new Mock <IGeometryRepository>(); repositoryMock.Setup(x => x.GetFigureAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new TestEntity()); //Act GeometryService service = GetGeometryService(repositoryMock.Object); //Assert var result = await service.FindFigureAsync(1, CancellationToken.None); Assert.AreEqual(3, result.GetArea()); }