Beispiel #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="locationId"></param>
        /// <returns></returns>
        public EquipmentCollectionDto GenerateEquipmentCollectionDto(string locationId)
        {
            var criteria = this.GenerateEquipmentCriteria(locationId);
            EquipmentCollectionDto equipColl = new EquipmentCollectionDto();
            equipColl.Add(new EquipmentDto());

            equipColl[0].HeadendCode = "01";
            equipColl[0].LocationId = locationId;
            equipColl[0].Status = criteria.Status;
            equipColl[0].SerialNumber = criteria.SerialNumber;
            EquipmentDto eDto = new EquipmentDto();
            eDto.HeadendCode = "01";
            eDto.LocationId = locationId;
            eDto.SerialNumber = criteria.SerialNumber;
            eDto.Status = criteria.Status;
            eDto.Type.Model = criteria.Model;

            using (var client = new RosettianClient())
            {
                var user = CurrentUser.AsUserDto();
                client.CreateEquipment(eDto, user);
            }
            return equipColl;
        }
        public void ToVideoDeviceList_EquipmentListHasOntAndAllTypesOfVideoDevices_ValidateAbleToMapEquipmentListToSerializableVideoDeviceList()
        {
            // Given a list of equipment
            var equipmentList = new EquipmentCollectionDto();

            // And the equipment list contains a ont port
            var ontPort = TestEquipment_ONTPort();
            equipmentList.Add(ontPort);

            // And the equipment list contains a dvr
            var dvr = TestEquipment_DVR();
            equipmentList.Add(dvr);

            // And the equipment list contains a cable card
            var cableCard = TestEquipment_CableCard();
            equipmentList.Add(cableCard);

            // And the equipment list contains a router
            var router = TestEquipment_Router();
            equipmentList.Add(router);

            // And the equipment list contains a non hd capable set top box
            var stb = TestEquipment_SetTopBox();
            equipmentList.Add(stb);

            // And the equipment list contains a digital adapter
            var da = TestEquipment_DigitalAdapter();
            equipmentList.Add(da);

            // And the equipment list contains a video access point
            var vap = TestEquipment_VideoAccessPoint();
            equipmentList.Add(vap);

            // And The equipment list contains a TiVo
            var tivo = TestEquipment_TiVo();
            equipmentList.Add(tivo);

            // When mapping the list equipment to serializable video device list
            var videoDeviceList = equipmentList.ToVideoDeviceList();

            // Then we receive a response
            Assert.IsNotNull(videoDeviceList);

            // And the response is successful
            // And the device count matches with the requested device list count
            Assert.AreEqual(equipmentList.Count, videoDeviceList.Count, "Device count does not match");

            // And the ont device id matches with the requested ont device id
            // And the ont model matches with the request ont model
            // And the ont device type mapped with type of ""
            var actualMappedOntPort = videoDeviceList.Where(x => x.Serial == ontPort.SerialNumber && x.Type=="" && x.Model==ontPort.Type.Model);
            Assert.IsTrue(actualMappedOntPort!=null && actualMappedOntPort.Count() == 1);

            // And the dvr id matches with the requested dvr id
            // And the dvr model matches with the requested dvr model
            // And the dvr mapped with type of DVR
            var actualMappedVideoDevice = videoDeviceList.Where(x => x.Serial == dvr.SerialNumber && x.Type=="DVR" && x.Model==dvr.Type.Model);
            Assert.IsTrue(actualMappedVideoDevice != null && actualMappedVideoDevice.Count() == 1);

            // And the cable card id matches with the requested cable card id
            // And the cable card model matches with the requested cable card model
            // And the cable card mapped with type of CC
            var actualMappedCableCard = videoDeviceList.Where(x => x.Serial == cableCard.SerialNumber && x.Type == "CC" && x.Model == cableCard.Type.Model);
            Assert.IsTrue(actualMappedCableCard != null && actualMappedCableCard.Count() == 1);

            // And the stb id matches with the requested router id
            // And the stb model matches with the requested stb model
            // And the stb mapped with type of SD
            var actualMappedStb= videoDeviceList.Where(x => x.Serial == stb.SerialNumber && x.Type.TrimEnd().EndsWith("SD") && x.Model == stb.Type.Model);
            Assert.IsTrue(actualMappedStb != null && actualMappedStb.Count() == 1);

            // And the digital adapter id matches with the requested router id
            // And the digital model matches with the requested digital model
            // And the digital adapter mapped with type of DA
            var actualMappedDigitalAdapter = videoDeviceList.Where(x => x.Serial == da.SerialNumber && x.Type == "DA" && x.Model == da.Type.Model);
            Assert.IsTrue(actualMappedDigitalAdapter != null && actualMappedDigitalAdapter.Count() == 1);

            // And the vap id matches with the requested router id
            // And the vap model matches with the requested digital model
            // And the vap mapped with type of VAP
            var actualMappedVap = videoDeviceList.Where(x => x.Serial == vap.SerialNumber && x.Type == "VAP" && x.Model == vap.Type.Model);
            Assert.IsTrue(actualMappedVap != null && actualMappedVap.Count() == 1);

            // And the TiVo id matches with the requested tivo id
            // And the TiVo model matches with the requested Tivo Model
            // And the TiVo mapped with type of Gateway
            var actualMappedTiVo = videoDeviceList.Where(x => x.Serial == tivo.SerialNumber && x.Type.ToUpper() == "TIVO" && x.Model.ToUpper() == "GATEWAY");
            Assert.IsTrue(actualMappedTiVo != null && actualMappedTiVo.Count() == 1, "TiVo did not map properly");
        }
        public void EditBlockedServicesMethod_SomeBlocked()
        {
            // Arrange
            PartialViewResult resultEditBlockedServices = null;
            string expectedServicesAsJSON = null;
            ServicesModel actualServicesModel = null;
            List<ServiceDto> expectedServiceList = null;
            ServiceCollectionDto actualServices = null;
            SubscriberDto expectedSubscriber = SIMPL.Test.IntegrationTest.Data.Data.GetSIMPLSubscriber04CPE01();
            Assert.IsNotNull(expectedSubscriber, "subscriber");
            Assert.IsNotNull(expectedSubscriber.ID, "subscriber.ID");

            EquipmentCollectionDto ec = new EquipmentCollectionDto();
            ec.Add(new EquipmentDto());
            ec[0].AssociatedSubscriberId = expectedSubscriber.ID;
            ec[0].BlockedServiceList.Add(new ServiceDto());
            ec[0].BlockedServiceList[0] = new ServiceDto
            {
                ClassName = ServiceClassType.ProvisionedOntDataPort.GetStringValue(),
                Name = "ENET",
                Description = "RJ-45 ETHERNET PORT"
            };

            expectedSubscriber.Accounts[0].Equipment = new EquipmentCollectionDto();
            expectedSubscriber.Accounts[0].Equipment.Add(ec[0]);

            EquipmentDto expectedDevice = expectedSubscriber.Accounts[0].Equipment.FirstOrDefault();
            Assert.IsNotNull(expectedDevice, "expectedDevice");

            expectedDevice.BlockedServiceList = new ServiceCollectionDto();
            expectedDevice.BlockedServiceList.AddRange(expectedSubscriber.Accounts[0].Services.GetRange(0, 2));

            using (RosettianClient client = new RosettianClient())
            {
                client.UpdateEquipment(expectedDevice, RosettianUser);
            }

            expectedServicesAsJSON = ServicesControllerHelper.ConvertServicesToJSON(expectedDevice.BlockedServiceList);
            Assert.IsNotNull(expectedServicesAsJSON, "expectedServicesAsJSON");

            // Act
            resultEditBlockedServices = ServicesControllerForTests.EditBlockedServices(expectedServicesAsJSON, expectedSubscriber.ID, expectedDevice.SerialNumber, "") as PartialViewResult;

            // Assert - First group
            Assert.IsNotNull(resultEditBlockedServices, "resultEditBlockedServices");

            // Arrange/Act - Second group
            actualServicesModel = resultEditBlockedServices.Model as ServicesModel;

            // Assert - Second group
            Assert.IsNotNull(actualServicesModel, "actualServicesModel");
            Assert.IsNull(actualServicesModel.ServicesActionResult, "ServicesActionResult is not null");
            Assert.AreEqual(expectedSubscriber.ID, actualServicesModel.SubscriberID, "Subscriber.ID compared to SubscriberID");
            Assert.AreEqual(3, actualServicesModel.SubscriberServicesList.Count, "actualServicesModel.SubscriberServicesList.Count");

            // Arrange/Act - Third group
            expectedServiceList = expectedSubscriber.Accounts[0].Services.OrderBy(x => x.Name).ToList();
            actualServices = ServicesControllerHelper.ConvertJSONToServices(actualServicesModel.ServicesAsJSON);

            // Assert - Third group
            int i = 0;
            foreach (ServiceDto individualService in actualServices)
            {
                Assert.AreEqual(expectedServiceList[i].Name, individualService.Name, "Service Name - index count {0}", i);
                Assert.AreEqual(expectedServiceList[i].Description, individualService.Description, "Service Description - index count {0}", i);
                Assert.AreEqual(expectedServiceList[i].ClassName, individualService.ClassName, "Service ClassName - index count {0}", i);
                i++;
            }

            // Assert - Third group (continued)
            string message = string.Empty;
            // Validate Blocked Services displayed matches the actualViewModel blocked services
            bool resultOfValidation = this.ValidateBlockedServices(expectedDevice.BlockedServiceList, actualServicesModel.BlockedServicesList, out message);
            Assert.IsTrue(resultOfValidation, message);
        }
Beispiel #4
0
        /// <summary>
        /// NewEquipmentCollection - provides a new EquipmentCollectionDto 
        /// </summary>
        /// <param name="collectionSize"></param>
        /// <returns></returns>
        public static EquipmentCollectionDto NewEquipmentCollection(int collectionSize = 0)
        {
            var equipCollection = new EquipmentCollectionDto();
            var rand = new Random();
            if (collectionSize <= 0)
            {
                collectionSize = rand.Next(4, 12);
            }

            var equipmentCategories = Enum.GetValues(typeof (EquipmentCategoryDto));

            for (var i = 0; i < collectionSize; i++)
            {
                var category = (EquipmentCategoryDto) equipmentCategories.GetValue(rand.Next(equipmentCategories.Length));

                // currently, no items exist for these categories so they must be excluded: ONT, ONTVdslPort, Modem
                while (category == EquipmentCategoryDto.ONT ||
                    category == EquipmentCategoryDto.ONTVdslPort ||
                    category == EquipmentCategoryDto.Modem ||
                    category == EquipmentCategoryDto.UnKnown ||
                    category == EquipmentCategoryDto.None)
                {
                    category = (EquipmentCategoryDto)equipmentCategories.GetValue(rand.Next(equipmentCategories.Length));
                }

                equipCollection.Add(NewEquipment(category));
            }

            return equipCollection;
        }