public void CreateUnit_ValidUnit_CreatesUnit()
        {
            //Act
            var unit = _unitService.CreateUnit(ValidUnit);

            //Assert
            Assert.IsInstanceOfType(unit, typeof(Unit));
            Guid guidOut;

            Assert.IsTrue(Guid.TryParse(unit.UnitId, out guidOut));
            Assert.IsTrue(unit.Description.Length > 0);
            Assert.IsTrue(unit.Mileage >= 0.0);
        }
        public IHttpActionResult Post(FunctionalUnitRequest unit)
        {
            var result = UnitService.CreateUnit(unit);

            return(Created <Entidad>("", new Entidad {
                Id = result.Id
            }));
        }
Exemple #3
0
    public void CreateUnit()
    {
        using var context = new InMemoryDbContext();
        var testee     = new UnitService(new SimpleCrudHelper(context, TestMapper.Create()));
        var newUnitDto = new NewUnitDto("Piece");

        testee.CreateUnit(newUnitDto);

        context.Units.Should().Contain(x => x.Name == "Piece");
    }