Beispiel #1
0
        public async Task Test_AddOffer_ShouldAddOffer()
        {
            var offer = new EditOfferDTO
            {
                Title = "NewlyAdded"
            };

            var context = await GetContext();

            var offerRepo    = new DbRepository <Offer>(context);
            var offerService = new OfferService(offerRepo);
            int result       = await offerService.EditOffer(offer);

            Assert.Equal(5, context.Offers.CountAsync().Result);
            Assert.Contains("NewlyAdded", context.Offers.Select(p => p.Title).ToArray());
        }
        public async Task Test_EditOffer_ShouldUpdateOffer()
        {
            var context = await GetContext();

            var offerRepo    = new DbRepository <Offer>(context);
            var offerService = new OfferService(offerRepo);

            var editDto = new EditOfferDTO
            {
                Id    = 72,
                Title = "Edited offer"
            };
            int id = await offerService.EditOffer(editDto);


            var offers           = context.Offers.ToArray();
            var editedOfferTitle = offerService.GetTitleById(id);

            Assert.Equal("Edited offer", context.Offers
                         .SingleOrDefault(p => p.Id == id)
                         .Title);
        }