Пример #1
0
        public async Task ModifyAsync_GoodParams_ReturnOk()
        {
            //Arrange
            ISuppliesUnitOfWork suppliesUnitOfWorkStub = Substitute.For <ISuppliesUnitOfWork>();

            Supply supply = new Supply(1, 1, DateTimeOffset.Now, 10)
            {
                Id       = 1,
                IsDelete = false,
                Provider = new Provider()
                {
                    Name = "Лютик"
                },
                EquipmentType = new EquipmentType("Молоток")
            };

            //Act
            SuppliesService suppliesService = new SuppliesService(suppliesUnitOfWorkStub);
            //await suppliesService.CreateAsync(supply);

            //Assert
            Exception ex = await Record.ExceptionAsync(() => suppliesService.ModifyAsync(supply));

            Assert.Null(ex);
        }
Пример #2
0
        public async Task CreateRangeAsync_BadParams_AlwaysException()
        {
            //Arrange
            ISuppliesUnitOfWork suppliesUnitOfWorkStub = Substitute.For <ISuppliesUnitOfWork>();


            //Act
            SuppliesService suppliesService = new SuppliesService(suppliesUnitOfWorkStub);

            //Assert
            await Assert.ThrowsAsync <ArgumentNullException>(() => suppliesService.CreateAsync(null));
        }
Пример #3
0
        public async Task ModifyAsync_GoodParamsButHasDeleted_AlwaysException()
        {
            //Arrange
            ISuppliesUnitOfWork suppliesUnitOfWorkStub = Substitute.For <ISuppliesUnitOfWork>();

            Supply supply = new Supply {
                Id = 5, EquipmentTypeName = "Наименование", IsDelete = true
            };

            //Act
            SuppliesService suppliesService = new SuppliesService(suppliesUnitOfWorkStub);

            //Assert
            await Assert.ThrowsAsync <InvalidOperationException>(() => suppliesService.ModifyAsync(supply));
        }
Пример #4
0
        public async Task RemoveAsync_GoodParams_ReturnOk()
        {
            //Arrange
            ISuppliesUnitOfWork suppliesUnitOfWorkStub = Substitute.For <ISuppliesUnitOfWork>();

            Supply supply = new Supply {
                Id = 5, EquipmentTypeName = "Наименование"
            };

            //Act
            SuppliesService suppliesService = new SuppliesService(suppliesUnitOfWorkStub);

            //Assert
            Exception ex = await Record.ExceptionAsync(() => suppliesService.RemoveAsync(supply));

            Assert.Null(ex);
            Assert.True(supply.IsDelete);
        }
Пример #5
0
        public async Task ModifyAsync_GoodParamsButHasDeleted_AlwaysExceptionWithMessage()
        {
            //Arrange
            ISuppliesUnitOfWork suppliesUnitOfWorkStub = Substitute.For <ISuppliesUnitOfWork>();

            Supply supply = new Supply {
                Id = 5, EquipmentTypeName = "Наименование", IsDelete = true
            };

            //Act
            SuppliesService suppliesService = new SuppliesService(suppliesUnitOfWorkStub);

            //Assert
            InvalidOperationException ex =
                await Assert.ThrowsAsync <InvalidOperationException>(() => suppliesService.ModifyAsync(supply));

            Assert.Contains("Операция редактирования отменена. Запрещено модифицировать удаленную поставку",
                            ex.Message);
        }