예제 #1
0
        public void SetDeliveryGroupsHotmailMonitoring()
        {
            var repositoryMock = new Mock<IBaseRepository<DeliveryGroup>>();
            var deliveryGroupClone = (IEnumerable<DeliveryGroup>) DeliveryGroups.Clone();
            bool called = false;

            repositoryMock.Setup(m => m.Get()).Returns(DeliveryGroups.AsQueryable());
            repositoryMock.Setup(m => m.Sync(true, true)).Callback(() => called = true);
            var deliveryGroupService = new DeliveryGroupService(repositoryMock.Object);
            var enabledDeliveryGroups = deliveryGroupService.GetEnabledDeliveryGroups();

            var dvgsToEnable = deliveryGroupClone.Where(d => !d.CancelOnBulkingEnabled).ToList();
            var dvgsToDisable = deliveryGroupClone.Where(d => d.CancelOnBulkingEnabled).ToList();

            dvgsToDisable.ForEach(d => d.CancelOnBulkingEnabled = false);
            dvgsToEnable.ForEach(d => d.CancelOnBulkingEnabled = true);

            deliveryGroupService.BulkUpdateRepository(deliveryGroupClone,
                                            new Expression<Func<DeliveryGroup, object>>[]
                                            {
                                                d => d.CancelOnBulkingEnabled
                                            },
                                            true);

            Assert.IsFalse(DeliveryGroups.Join(deliveryGroupClone, t => t.Id, s => s.Id, (t, s) => new { t, s }).Any(j => j.t.CancelOnBulkingEnabled != j.s.CancelOnBulkingEnabled),
                                                "Bit flip failed");

            Assert.IsTrue(called, "Sync not called");
        }
예제 #2
0
        // POST api/monitoreddvgs
        public HttpResponseMessage Post(IEnumerable<DeliveryGroup> updatedDeliveryGroups)
        {
            try
            {
                var dvgService = new DeliveryGroupService(new Repository<DeliveryGroup>(_session));
                
                dvgService.BulkUpdateRepository(updatedDeliveryGroups,
                    new Expression<Func<DeliveryGroup, object>>[]
                        {
                            d => d.CancelOnBulkingEnabled
                        },
                        true
                    );
                return Get();
            }
            catch (Exception ex)
            {
                var response = Request.CreateResponse(HttpStatusCode.InternalServerError);

                HttpResponseHelper.SetExceptionHeaders(response, ex, "Update Failed");

                return response;
            }
        }
예제 #3
0
        public void GetActiveDeliveryGroups()
        {
            var repositoryMock = new Mock<IBaseRepository<DeliveryGroup>>();

            repositoryMock.Setup(m => m.Get()).Returns(DeliveryGroups.AsQueryable());
            var deliveryGroupService = new DeliveryGroupService(repositoryMock.Object);

            Assert.IsTrue(deliveryGroupService.GetEnabledDeliveryGroups().Count() == 2);
        }
예제 #4
0
        public void SetDeliveryGroupsConfig()
        {
            var repositoryMock = new Mock<IBaseRepository<DeliveryGroup>>();
            DeliveryGroup[] deliveryGroupsPostSave = null;
            bool called = false;

            repositoryMock.Setup(m => m.Get()).Returns(DeliveryGroups.AsQueryable());
            repositoryMock.Setup(m => m.Sync(true,true)).Callback(() => called = true);
            var deliveryGroupService = new DeliveryGroupService(repositoryMock.Object);
            var enabledDeliveryGroups = deliveryGroupService.GetEnabledDeliveryGroups();

            deliveryGroupService.SetVMTAConfiguration(enabledDeliveryGroups.Select(d => d.Id), " ",true);

            Assert.IsTrue(deliveryGroupsPostSave == null, "Empty string config accepted");

            deliveryGroupService.SetVMTAConfiguration(enabledDeliveryGroups.Select(d => d.Id), "Test",true);

            Assert.IsTrue(called, "Save not called");
            Assert.IsTrue(enabledDeliveryGroups.Count(d => d.UseCustomVMTA) == enabledDeliveryGroups.Count(), "UseCustomVMTA property not set as expected");
            Assert.IsTrue(enabledDeliveryGroups.Count(d => d.CustomVMTA == "Test") == 2, "CustomVMTA string not set as expected");
            Assert.IsTrue(enabledDeliveryGroups.Count(d => d.VMTAStatus == 1) == 2, "VMTAStatus not set as expected");
        }