Beispiel #1
0
        public void Update_Valid()
        {
            //arange
            PlanesService service = new PlanesService(unitOfWork, mapper, validator);

            var expected = new Plane
            {
                Id = 1, DepartureId = 1, PlaneTypeId = 1, Name = "dfg4456", ReleaseDate = new DateTime(1995, 1, 22)
            };

            var DtoToMake = new PlaneDto
            {
                Id = 1, DepartureId = 1, PlaneTypeId = 1, Name = "dfg4456", ReleaseDate = new DateTime(1995, 1, 22)
            };


            //act
            service.Update(DtoToMake);

            var actual = (unitOfWork.Set <Plane>() as FakeRpository <Plane>).updatedItem;

            //assert
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.DepartureId, actual.DepartureId);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.ReleaseDate, actual.ReleaseDate);
        }
Beispiel #2
0
        public PlanesController()
        {
            _airportPlanesService = new PlanesService();
            var mapperConfig = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <PlanePostModel, PlaneModel>();
                cfg.CreateMap <PlaneViewModel, PlaneModel>().ReverseMap();
            });

            _mapper = new Mapper(mapperConfig);
        }
Beispiel #3
0
        public void Update_UnValid()
        {
            //arange
            PlanesService service = new PlanesService(unitOfWork, mapper, validator);

            var DtoToMake = new PlaneDto
            {
                Id = 1, DepartureId = default(int), Name = "", ReleaseDate = new DateTime(1995, 1, 22)
            };

            //act
            service.Update(DtoToMake);

            var actual = (unitOfWork.Set <Plane>() as FakeRpository <Plane>).updatedItem;

            //assert
            Assert.IsNull(actual);
        }
Beispiel #4
0
        public void Make_UnValid()
        {
            //arange
            PlanesService service = new PlanesService(unitOfWork, mapper, validator);


            var DtoToMake = new PlaneDto
            {
                Id = 1, DepartureId = 1, Name = "dfgdghdfhgdfghfdghdfhdfgh4456", ReleaseDate = new DateTime(1995, 1, 22)
            };


            //act
            service.Make(DtoToMake);

            var actual = (unitOfWork.Set <Plane>() as FakeRpository <Plane>).createdItem;

            //assert
            Assert.IsNull(actual);
        }