Ejemplo n.º 1
0
        public void GetOffersFilter()
        {
            int      id            = 0;
            DateTime dateOfPosting = DateTime.Now;
            string   from          = "Ukraine";
            string   to            = "Poland";
            DateTime dateOfLoading = DateTime.Now;
            Vehicle  vehicle       = new Vehicle()
            {
                VehicleId = 1,
                Type      = VehicleType.Box,
                Weight    = 25
            };
            Carrier carrier = new Carrier()
            {
                CarrierId   = 1,
                Name        = "John",
                Email       = "*****@*****.**",
                PhoneNumber = "+123456789",
                VehicleId   = 1,
                Vehicle     = vehicle
            };
            Offer offer = new Offer()
            {
                OfferId       = id,
                DateOfLoading = dateOfLoading,
                DateOfPosting = dateOfPosting,
                From          = from,
                To            = to,
                CarrierId     = 1,
                Carrier       = carrier
            };

            Filter filter = new Filter(

                minDateOfPosting: dateOfPosting,
                from: from,
                type: vehicle.Type,
                maxWeight: vehicle.Weight
                );

            OfferController offerController = new OfferController();

            offerController.AddOffer(offer);
            var res = offerController.GetOffers(filter);

            Assert.IsTrue(res.Count == 1);
        }
        public async Task AddNewOfferTest()
        {
            SetMockContext("bakalam");
            AddNewOfferViewModel model = new AddNewOfferViewModel
            {
                AccommodationName = "nowododananazwa",
                City        = "nowemiasto",
                Description = "nowyopis",
                StartDate   = new DateTime(2015, 12, 25),
                EndDate     = new DateTime(2015, 12, 29),
                LocalNumber = "1",
                PostalCode  = "11-111",
                Price       = "123",
                RoomNumber  = "123",
                Street      = "nowaulica",
                AvailiableVacanciesNumber = "123",
            };
            int count  = _context.Offers.Count();
            var result = await _controller.AddOffer(model);

            Assert.IsNotNull(result);
        }