예제 #1
0
        public async Task SaveFigure_ThrowsNullArg_ModelIsEmpty()
        {
            //Arrange
            Mock <IGeometryRepository> repositoryMock = new Mock <IGeometryRepository>();

            //Act
            GeometryService service = GetGeometryService(repositoryMock.Object);

            //Assert
            Assert.ThrowsAsync <ArgumentNullException>(() => service.SaveFigureAsync(null, CancellationToken.None));
        }
예제 #2
0
        public async Task SaveFigure_ThrowsException_SomeException()
        {
            //Arrange
            Mock <IGeometryRepository> repositoryMock = new Mock <IGeometryRepository>();

            repositoryMock.Setup(x => x.SaveFigureAsync(It.IsAny <FigureBase>(), It.IsAny <CancellationToken>()))
            .ThrowsAsync(new NotImplementedException());

            //Act
            GeometryService service = GetGeometryService(repositoryMock.Object);

            //Assert
            Assert.ThrowsAsync <NotImplementedException>(() => service.SaveFigureAsync(new TestEntity(), CancellationToken.None));
        }
예제 #3
0
        public async Task SaveFigure_Success()
        {
            //Arrange
            Mock <IGeometryRepository> repositoryMock = new Mock <IGeometryRepository>();

            repositoryMock.Setup(x => x.SaveFigureAsync(It.IsAny <FigureBase>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(1);

            //Act
            GeometryService service = GetGeometryService(repositoryMock.Object);
            TestEntity      model   = new TestEntity();

            //Assert
            Assert.AreEqual(1, await service.SaveFigureAsync(model, CancellationToken.None));
        }