public void CreateONT_NewRg_ValidateUserAbleToCreateNewRg() { using (ShimsContext.Create()) { // Given a user that has permission to create new ont ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject(); ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UserEntityGet = () => new Entity { Email = "*****@*****.**" } }; // And the new rg to be created has all valid info var createOntModel = new CreateOntModel { SerialNumber = "123456789012345", LocationId = "HEADEND 04 INVENTORY", Status = "IGNORE", SelectedOntModel = "ARRIS RG", MacAddress = "A0:B1:C2:D3:E4:F5", SelectedManufacturerOui = "001E46", IsResidentialGateway = true, Manufacturer = "Arris" }; // When creating new rg with the valid rg info ShimRosettianClient.AllInstances.CreateONTEquipmentCriteriaDtoUserDto = (myTestClient, myEquipmentCriteria, myUserDto) => { }; ShimEmailer.AllInstances .SendDefinedEmailTypeIEnumerableOfStringItxOrderInt32StringEquipmentCriteriaDtoStringDictionaryOfStringString = (myEmailer, myemailType, myAddresses, myItxOrder, myMasterOrderId, myUserEmail, myEquipCriteriaDto, myMaufacturer, myMigrationParams) => { }; var searchController = DependencyResolver.Current.GetService<SearchController>(); var actionResponse = searchController.CreateONT(createOntModel) as JsonResult; // Then the user receives a response Assert.IsNotNull(actionResponse, "CreateONT method returned null"); // And the response is successful // And the rg serial number created matches the requested rg serial and manufacturer Assert.IsNotNull(actionResponse.Data, "CreateONT response data is null"); var jss = new JavaScriptSerializer(); var expectedResult = new { status = "valid", newONTSerial = createOntModel.SerialNumber }.ToJSON(); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON())); } }
public void CreateONT_NewRg_MissingMacAddress_MissingUnitAddress_ValidateUserReceivesError() { using (ShimsContext.Create()) { // Given a user that has permission to create new rg // And the new rg to be created is missing MacAddress and ManufacturerOUI/UnitAddress var createOntModel = new CreateOntModel { SerialNumber = "1234567", LocationId = "HEADEND 04 INVENTORY", Status = "IGNORE", SelectedOntModel = "ARRIS RG", IsResidentialGateway = true, Manufacturer = "Arris" }; // When creating new rg with the missing required fields var searchController = DependencyResolver.Current.GetService<SearchController>(); var result = searchController.CreateONT(createOntModel) as JsonResult; // Then the user receives a response Assert.IsNotNull(result, "CreateONT json result is null"); Assert.IsNotNull(result.Data, "CreateONT json result data is null"); // And the response is an error // And the error tells user which required fields are missing var jss = new JavaScriptSerializer(); var expectedResult = new // { status = "error", errorMessage = "MacAddress and ManufacturerOUI/UnitAddress are required for Residential Gateway creation!" }.ToJSON(); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(result.Data.ToJSON())); } }
public void CreateONT_NewRg_ValidateUserAbleToCreateNewRg() { // Given a user that has permission to create new ont // And the new rg to be created has all valid info var serialNumber = DateTime.Now.ToString("ddMMyyhhmmssff"); var createOntModel = new CreateOntModel { SerialNumber = serialNumber, LocationId = "HEADEND 04 INVENTORY", Status = "IGNORE", SelectedOntModel = "ARRIS RG", MacAddress = "A0:B1:C2:D3:E4:F5", SelectedManufacturerOui = "001E46", IsResidentialGateway = true, Manufacturer = "Arris" }; // When creating new rg with the valid rg info var actionResult = SearchControllerForTest.CreateONT(createOntModel) as JsonResult; // Then the user receives a response Assert.IsNotNull(actionResult, "CreateONT json result is null"); // And the response is successful Assert.IsNotNull(actionResult.Data, "CreateONT json result data is null"); var jss = new JavaScriptSerializer(); var expectedResult = new { status = "valid", newONTSerial = createOntModel.SerialNumber }.ToJSON(); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResult.Data.ToJSON())); // And the rg is created in provisioning system (triad) successfully var rgDataPort = string.Format("{0}D01", serialNumber); var loadedRgDataPort = DataHelper.LoadEquipment(rgDataPort, true); // And the rg created matches the requested rg Assert.AreEqual(rgDataPort, loadedRgDataPort.SerialNumber, "SerialNumber does not match!"); // And the rg created on the requested location Assert.AreEqual(createOntModel.LocationId, loadedRgDataPort.LocationId, "LoactionId does not match!"); // And the rg created with the requested status Assert.AreEqual(createOntModel.Status, loadedRgDataPort.Status, "Status does not match!"); // And the rg created with the requested model Assert.AreEqual(createOntModel.SelectedOntModel, loadedRgDataPort.Type.ONTModel.Model, "ONTModel does not match!"); // And the rg created with the requested unit address Assert.AreEqual(createOntModel.SelectedManufacturerOui, loadedRgDataPort.UnitAddress, "UnitAddress does not match!"); // And the rg created with the requested mac address Assert.IsNotNull(loadedRgDataPort.CustomFields, "CustomFields shouldn't be null!"); var macAddressCutomField = loadedRgDataPort.CustomFields.FirstOrDefault(x => x.Label == "ENET_MAC_ADDR"); Assert.IsNotNull(macAddressCutomField, "MacAddress cuetomfield shouldn't be null!"); Assert.AreEqual(createOntModel.MacAddress, macAddressCutomField.Value, "MacAddress does not match!"); }
public void User_tries_to_create_a_new_ONT_and_receives_a_Rosettian_error() { using (ShimsContext.Create()) { //Arrange // Given a user that has permission to create new ont ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject(); ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UserEntityGet = () => new Entity { Email = "*****@*****.**" } }; // And the new ont to be created has all valid info var createOntModel = new CreateOntModel { SerialNumber = "12345678", LocationId = "HEADEND 04 INVENTORY", Status = "IGNORE", SelectedOntModel = "ONT1000M", IsResidentialGateway = false, Manufacturer = "Motorola" }; // When creating new ont with the valid ont info ShimRosettianClient.AllInstances.CreateONTEquipmentCriteriaDtoUserDto = (myTestClient, myEquipmentCriteria, myUserDto) => { }; //This is for creating a Fault exception const string expectedErrorMessage = "This is a fault exception message"; var faultDetail = new ValidationDetailDto() { Message = expectedErrorMessage }; var faultDetails = new List<ValidationDetailDto>(); faultDetails.Add(faultDetail); var validationFault = new ValidationFaultDto() { Details = faultDetails }; var fault = new FaultException<ValidationFaultDto>(validationFault); //Have Controller CreateONT method throw the fault when called ShimRosettianClient.AllInstances.CreateONTEquipmentCriteriaDtoUserDto = delegate { throw fault; }; //Add var searchController = DependencyResolver.Current.GetService<SearchController>(); var actionResponse = searchController.CreateONT(createOntModel) as JsonResult; //Assert // Then the user receives a response Assert.IsNotNull(actionResponse, "CreateONT method returned null"); // And the response is successful // And the ont serial number created matches the requested ont serial and manufacturer Assert.IsNotNull(actionResponse.Data, "CreateONT response data is null"); var jss = new JavaScriptSerializer(); var expectedResult = new { status = "error", errorMessage = "This is a fault exception message" }.ToJSON(); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON())); } }
public void CreateONT_NewOnt_ValidateUserAbleToCreateNewOnt() { // Given a user that has permission to create new ont // And the new ont to be created has all valid info var serialNumber = DateTime.Now.ToString("ddMMhhmm"); var createOntModel = new CreateOntModel { SerialNumber = serialNumber, LocationId = "HEADEND 04 INVENTORY", Status = "IGNORE", SelectedOntModel = "ONT1000M", MacAddress = "A0B1C2D3E4F5", SelectedManufacturerOui = "001E46", IsResidentialGateway = false, Manufacturer = "Motorola" }; // When creating new ont with the valid ont info var actionResponse = SearchControllerForTest.CreateONT(createOntModel) as JsonResult; // Then the user receives a response Assert.IsNotNull(actionResponse, "CreateONT json result is null"); // And the response is successful // And the ont serial number created matches the requested ont serial and manufacturer Assert.IsNotNull(actionResponse.Data, "CreateONT json result data is null"); var jss = new JavaScriptSerializer(); var expectedResult = new { status = "valid", newONTSerial = createOntModel.Manufacturer.ToMfrCode() + createOntModel.SerialNumber }.ToJSON(); Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON())); // And the ont is created in provisioning system (triad) successfully var ontDataPort = string.Format("{0}D01", createOntModel.Manufacturer.ToMfrCode() + createOntModel.SerialNumber); var loadedDataPort = DataHelper.LoadEquipment(ontDataPort, true); // And the ont created matches the requested equipment Assert.AreEqual(ontDataPort, loadedDataPort.SerialNumber, "SerialNumber does not match!"); // And the ont created on the requested location Assert.AreEqual(createOntModel.LocationId, loadedDataPort.LocationId, "LoactionId does not match!"); // And the ont created with the requested status Assert.AreEqual(createOntModel.Status, loadedDataPort.Status, "Status does not match!"); // And the ont created with the requested unit address Assert.AreNotEqual(createOntModel.SelectedManufacturerOui, loadedDataPort.UnitAddress, "UnitAddress should be null or empty!"); // And the ont created with the requested model Assert.AreEqual(createOntModel.SelectedOntModel, loadedDataPort.Type.ONTModel.Model, "ONTModel does not match!"); Assert.IsNotNull(loadedDataPort.CustomFields, "CustomFields shouldn't be null!"); }