public void CreateEndpointWithValidInput() { Endpoint endpoint = new Endpoint() { serialNumber = "1", meterModelId = 16, meterNumber = 1, meterFirmwareVersion = "1", switchState = 0 }; Mock <IBaseDao <Endpoint> > mock = new Mock <IBaseDao <Endpoint> >(); mock.Setup(dao => dao.Create(endpoint)).Returns(endpoint); EndpointController endpointController = new EndpointController(); EndpointVO endpointVo = new EndpointVO() { serialNumber = "1", meterModelId = "nsx1p2w", meterNumber = "1", switchState = "Disconnected", meterFirmwareVersion = "1", }; var resultExpect = mock.Object.Create(endpoint); var result = endpointController.Create(endpointVo); Assert.AreEqual(resultExpect, result); }
private void InsertEndpointView() { Console.WriteLine(I18nService.GetTranslate("INSERT_NEW_ENDPOINT")); Console.Write(I18nService.GetTranslate("SERIAL_NUMBER") + ": "); var serialNumber = Console.ReadLine(); Console.Write(I18nService.GetTranslate("METER_MODEL_ID") + string.Format(" ({0} | {1} | {2} | {3}): ", ModelId.NSX1P2W, ModelId.NSX1P3W, ModelId.NSX1P4W, ModelId.NSX1P5W)); var modelId = Console.ReadLine(); Console.Write(I18nService.GetTranslate("METER_NUMBER") + ": "); var meterNumber = Console.ReadLine(); Console.Write(I18nService.GetTranslate("METER_FIRMWARE_VERSION") + ": "); var firmwareVersion = Console.ReadLine(); Console.Write(I18nService.GetTranslate("SWITCH_STATE") + string.Format(" ({0} | {1} | {2}): ", SwitchState.Disconnected, SwitchState.Connected, SwitchState.Armed)); var switchState = Console.ReadLine(); var newEndpoint = new EndpointVO() { serialNumber = serialNumber, meterModelId = modelId, meterNumber = meterNumber, meterFirmwareVersion = firmwareVersion, switchState = switchState }; var endpoint = endpointController.Create(newEndpoint); Console.WriteLine(I18nService.GetTranslate("SUCCESSLY_CREATED_ENDPOINT")); PressAnyKeyToContinue(); }
public void CreateEndpointWithEmptySerialNumber() { EndpointController endpointController = new EndpointController(); EndpointVO endpointVo = new EndpointVO() { meterModelId = "nsx1p2w", meterNumber = "1", switchState = "Disconnected", meterFirmwareVersion = "1", }; var result = endpointController.Create(endpointVo); }
public void CreateEndpointWithInvalidSwitchState() { EndpointController endpointController = new EndpointController(); EndpointVO endpointVo = new EndpointVO() { serialNumber = "1", meterModelId = "nsx1p2w", meterNumber = "1", switchState = "5", meterFirmwareVersion = "1", }; var result = endpointController.Create(endpointVo); }
public void CreateEndpointWithDuplicatedSerialNumber() { Endpoint endpoint = new Endpoint() { serialNumber = "1", meterModelId = 16, meterNumber = 1, meterFirmwareVersion = "1", switchState = 0 }; Mock <IBaseDao <Endpoint> > mock = new Mock <IBaseDao <Endpoint> >(); mock.Setup(dao => dao.FindOne(endpoint.serialNumber)).Returns(endpoint); EndpointController endpointController = new EndpointController(); EndpointVO endpointVo = new EndpointVO() { serialNumber = "1", meterModelId = "nsx1p2w", meterNumber = "1", switchState = "Disconnected", meterFirmwareVersion = "1", }; var result = endpointController.Create(endpointVo); }
public void CreateEndpointWithEmptyEndpoint() { EndpointController endpointController = new EndpointController(); EndpointVO endpointVo = new EndpointVO(); var result = endpointController.Create(endpointVo); }