Ejemplo n.º 1
0
        public async Task UnitService_Should_Update_Unit()
        {
            // Arrange
            SetUpUnitOfWork();
            var service = new UnitService(_unitOfWork.Object, _mapper);
            var entity  = new UnitDTO()
            {
                Name      = "TestName",
                ShortName = "TestSN",
            };

            var newEntity = new UnitDTO()
            {
                Name      = "NewTestName",
                ShortName = "NewTestSN",
            };

            await service.CreateAsync(entity);

            await _unitOfWork.Object.SaveAsync();

            // Act
            entity.Name      = newEntity.Name;
            entity.ShortName = newEntity.ShortName;
            await service.UpdateAsync(entity);

            await _unitOfWork.Object.SaveAsync();

            // Assert
            Assert.NotNull(entity);
            Assert.Equal(newEntity.Name, entity.Name);
            Assert.Equal(newEntity.ShortName, entity.ShortName);
        }
Ejemplo n.º 2
0
        public async Task UnitService_Should_Create_Unit_Async()
        {
            // Arrange
            SetUpUnitOfWork();
            var service        = new UnitService(_unitOfWork.Object, _mapper);
            var expectedEntity = new UnitDTO()
            {
                Name      = "TestName",
                ShortName = "TestSN",
            };

            // Act
            var actualEntity = await service.CreateAsync(expectedEntity);

            await _unitOfWork.Object.SaveAsync();

            // Assert
            Assert.NotNull(actualEntity);
            Assert.Equal(expectedEntity.Name, actualEntity.Name);
            Assert.Equal(expectedEntity.ShortName, actualEntity.ShortName);
        }
Ejemplo n.º 3
0
        public async Task UnitService_Should_Delete_Unit_Async()
        {
            // Arrange
            SetUpUnitOfWork();
            var service = new UnitService(_unitOfWork.Object, _mapper);
            var entity  = new UnitDTO()
            {
                Name      = "TestName",
                ShortName = "TestSN",
            };

            entity = await service.CreateAsync(entity);

            await _unitOfWork.Object.SaveAsync();

            // Act
            await service.DeleteAsync(entity.Id);

            await _unitOfWork.Object.SaveAsync();

            // Assert
            Assert.Null(await service.GetAsync(entity.Id));
        }