Пример #1
0
        public void AddCampaignMethod_CompleteRequest_Correct()
        {
            var dbLayer = new EfAdvertDbService(new s19191Context());

            var cont = new CampaignsController(dbLayer);

            var result = cont.AddCampaign(new AddCampaignRequest
            {
                IdClient            = 1,
                StartDate           = DateTime.Today,
                EndDate             = DateTime.Today.AddDays(2),
                PricePerSquareMeter = 35,
                FromIdBuilding      = 2,
                ToIdBuilding        = 5
            });

            Assert.IsNotNull(result);
            Assert.IsTrue(result is ObjectResult);
            var vr = (ObjectResult)result;

            Assert.IsNotNull(vr.Value);
            var vm = (AddCampaignResponse)vr.Value;

            Assert.IsNotNull(vm);
            Assert.IsTrue(Decimal.Compare(vm.TotalPrice, 1837.50m) == 0);
            Assert.IsTrue(vm.Campaign.IdClient == 1);
        }
Пример #2
0
        public void AddCampaignMethod_CompleteRequest_Correct()
        {
            var dbLayer = new Mock <IAdvertDbService>();
            AddCampaignRequest request = new AddCampaignRequest
            {
                IdClient            = 1,
                StartDate           = DateTime.Today,
                EndDate             = DateTime.Today.AddDays(2),
                PricePerSquareMeter = 25,
                FromIdBuilding      = 1,
                ToIdBuilding        = 4
            };

            dbLayer.Setup(d => d.AddCampaign(request))
            .Returns(new AddCampaignResponse
            {
                Campaign = new Campaign
                {
                    IdCampaign = 1,
                    IdClient   = 1,
                },
                TotalPrice = 25
            });

            var cont = new CampaignsController(dbLayer.Object);

            var result = cont.AddCampaign(request);

            Assert.IsNotNull(result);
            Assert.IsTrue(result is ObjectResult);
            var vr = (ObjectResult)result;

            Assert.IsNotNull(vr.Value);
            var vm = (AddCampaignResponse)vr.Value;

            Assert.IsNotNull(vm);
            Assert.IsTrue(vm.TotalPrice == 25);
            Assert.IsTrue(vm.Campaign.IdCampaign == 1);
            Assert.IsTrue(vm.Campaign.IdClient == 1);
        }