예제 #1
0
        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);
        }
예제 #2
0
        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();
        }
예제 #3
0
 public void CreateEndpointWithEmptySerialNumber()
 {
     EndpointController endpointController = new EndpointController();
     EndpointVO         endpointVo         = new EndpointVO()
     {
         meterModelId         = "nsx1p2w",
         meterNumber          = "1",
         switchState          = "Disconnected",
         meterFirmwareVersion = "1",
     };
     var result = endpointController.Create(endpointVo);
 }
예제 #4
0
 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);
 }
예제 #5
0
        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);
        }
예제 #6
0
 public void CreateEndpointWithEmptyEndpoint()
 {
     EndpointController endpointController = new EndpointController();
     EndpointVO         endpointVo         = new EndpointVO();
     var result = endpointController.Create(endpointVo);
 }