示例#1
0
 private void SetNextInput(long input)
 {
     if (_connector == null)
     {
         _connector = new TestConnector(AllOutput);
     }
     _connector.NextOutput = input;
 }
        public void T01_Successful2()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableIP(), GetConnectablePort()));
            t.WaitAndClose();

            Assert.IsTrue(c.Succeeded);
        }
        public void T03_NotConnectable1()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetUnreachableIP(), GetConnectablePort())); //存在しないホスト
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable1 [{0}]", c.ErrorMessage));
        }
        public void T04_NotConnectable2()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetUnknownDNSName(), GetConnectablePort())); //DNSエラー
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable2 [{0}]", c.ErrorMessage));
        }
        public void T05_NotConnectable3()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetClosedPort())); //ホストはあるがポートが開いてない
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable3 [{0}]", c.ErrorMessage));
        }
示例#6
0
        public void T01_Successful2()
        {
            TestConnector c = new TestConnector();
            TestClient    t = new TestClient();

            c.AsyncConnect(t, new TelnetParameter(GetConnectableIP(), GetConnectablePort()));
            t.WaitAndClose();

            Assert.IsTrue(c.Succeeded);
        }
示例#7
0
        public void T03_NotConnectable1()
        {
            TestConnector c = new TestConnector();
            TestClient    t = new TestClient();

            c.AsyncConnect(t, new TelnetParameter(GetUnreachableIP(), GetConnectablePort())); //存在しないホスト
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable1 [{0}]", c.ErrorMessage));
        }
示例#8
0
        public void T04_NotConnectable2()
        {
            TestConnector c = new TestConnector();
            TestClient    t = new TestClient();

            c.AsyncConnect(t, new TelnetParameter(GetUnknownDNSName(), GetConnectablePort())); //DNSエラー
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable2 [{0}]", c.ErrorMessage));
        }
示例#9
0
        public void T05_NotConnectable3()
        {
            TestConnector c = new TestConnector();
            TestClient    t = new TestClient();

            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetClosedPort())); //ホストはあるがポートが開いてない
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable3 [{0}]", c.ErrorMessage));
        }
示例#10
0
 private void CreateAndRunComputer(long[] instructions)
 {
     _computer = CreateComputer(instructions);
     if (_connector == null)
     {
         _connector = new TestConnector(AllOutput);
     }
     _computer.Connect(_connector);
     State      = _computer.Run();
     LastOutput = _connector.LastInput;
 }
示例#11
0
        public void ReturnsNullAsTriggerForNameWhenUnavailable()
        {
            // Arrange
            var trigger   = Mock.Of <IFlowTrigger>(o => o.Name == "test");
            var connector = new TestConnector();

            // Act
            var result = connector.GetTrigger("test");

            // Assert
            result.Should().BeNull();
        }
示例#12
0
        public void CreateConnectionReceivesNonNullConfiguration()
        {
            // Arrange
            var connector = new TestConnector();
            var config    = new object();

            // Act
            connector.GetConnection(config);

            // Assert
            connector.LastReceived.Should().Be((1, config));
        }
示例#13
0
        public void ReturnsNullAsActionForNameWhenUnavailable()
        {
            // Arrange
            var action    = Mock.Of <IFlowAction>(o => o.Name == "test");
            var connector = new TestConnector();

            // Act
            var result = connector.GetAction("test");

            // Assert
            result.Should().BeNull();
        }
示例#14
0
        public void ReturnsTriggerForNameWhenAvailable()
        {
            // Arrange
            var trigger   = Mock.Of <IFlowTrigger>(o => o.Name == "test");
            var connector = new TestConnector();

            // Act
            connector.AddTrigger(trigger);
            var result = connector.GetTrigger("test");

            // Assert
            result.Should().BeSameAs(trigger);
        }
示例#15
0
        public void T06_NegotiationFailed()
        {
            TestConnector c = new TestConnector();

            c.SetError(true);
            TestClient t = new TestClient();

            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetConnectablePort()));
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NegotiationFailed [{0}]", c.ErrorMessage));
        }
示例#16
0
        public void ReturnsActionForNameWhenAvailable()
        {
            // Arrange
            var action    = Mock.Of <IFlowAction>(o => o.Name == "test");
            var connector = new TestConnector();

            // Act
            connector.AddAction(action);
            var result = connector.GetAction("test");

            // Assert
            result.Should().BeSameAs(action);
        }
示例#17
0
        public void T07_Interrupt()
        {
            TestConnector c = new TestConnector();

            c.SetWait1Sec(true);
            TestClient t = new TestClient();

            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetConnectablePort()));
            Thread.Sleep(500);
            c.Interrupt();

            Assert.IsTrue(c.Interrupted);
            Assert.IsFalse(c.Succeeded);
            Assert.IsFalse(t.Notified); //Clientには成功・失敗とも通知されないはず
        }
示例#18
0
        public void GetConnectionReturnsSameConnectionForSameConfiguration()
        {
            // Arrange
            var connector = new TestConnector();
            var config    = new object();

            // Act
            var result1 = connector.GetConnection(config);
            var result2 = connector.GetConnection(config);

            // Assert
            using (new AssertionScope())
            {
                result1.Should().BeSameAs(result2);
                connector.LastReceived.Received.Should().Be(1);
            }
        }
示例#19
0
        private static async Task Main(string[] args)
        {
            var host = Host.CreateDefaultBuilder(args)
                       .UseConsoleLifetime()
                       .ConfigureAppConfiguration((hostContext, builder) =>
            {
                builder.AddUserSecrets <Program>();
            })
                       .ConfigureLogging((hostingContext, logging) =>
            {
                logging.AddConsole();
                logging.AddDebug();
            })
                       .ConfigureServices((hostContext, services) =>
            {
                services.AddOptions <TrainAnimatorOptions>();
                services.AddHostedService <DiscordTrainService>();

                services.AddSingleton <TrainAnimator>();
#if TestConnector
                services.AddSingleton <IControllerConnector, TestConnector>(services =>
                {
                    var connector = new TestConnector(services.GetRequiredService <ILogger <TestConnector> >());
                    connector.Initialize();
                    return(connector);
                });
#else
                services.AddSingleton <IControllerConnector, GpioControllerConnector>(services =>
                {
                    var options    = services.GetRequiredService <IOptions <GpioControllerConnectorOptions> >();
                    var logger     = services.GetRequiredService <ILogger <GpioControllerConnector> >();
                    var controller = new GpioControllerConnector(options, logger);
                    controller.Initialize();
                    return(controller);
                });
#endif

                services.AddSingleton(CreateDiscordSocketClient);
                services.AddSingleton(CreateDiscordCommandService);
            })
                       .Build();

            await host.RunAsync();
        }
示例#20
0
        public void GetConnectionReturnsDefaultConnectionForNullConfiguration()
        {
            // Arrange
            var connector         = new TestConnector();
            var config            = default(object);
            var defaultConnection = Mock.Of <IConnection>();

            connector.DefaultConnection = defaultConnection;

            // Act
            var result = connector.GetConnection(config);

            // Assert
            using (new AssertionScope())
            {
                result.Should().Be(defaultConnection);
                connector.LastReceived.Received.Should().Be(0);
            }
        }
示例#21
0
        private async void buttonCnTest_Click(object sender, RoutedEventArgs e)
        {
            if (!General.CheckPress())
            {
                MessageBox.Show("プレス治具のレバーを下げてください");
                return;
            }

            if (cnTesting)
            {
                return;
            }

            resetView();
            ResetLight();
            rbNon.IsChecked = true;

            cnTesting = true;
            RingCnTesting.IsActive = true;
            await TestConnector.CheckCn();

            State.VmCnPoint.ResultCn220 = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN220).一致率.ToString("F2");
            State.VmCnPoint.ResultCn223 = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN223).一致率.ToString("F2");
            State.VmCnPoint.ResultCn224 = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN224).一致率.ToString("F2");
            State.VmCnPoint.ResultCn225 = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN225).一致率.ToString("F2");
            State.VmCnPoint.ResultCn226 = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN226).一致率.ToString("F2");
            State.VmCnPoint.ResultJp1   = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.JP1).一致率.ToString("F2");
            State.VmCnPoint.ColCn220    = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN220).一致率 > State.TestSpec.MatchMin ? OkBrush : NgBrush;
            State.VmCnPoint.ColCn223    = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN223).一致率 > State.TestSpec.MatchMin ? OkBrush : NgBrush;
            State.VmCnPoint.ColCn224    = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN224).一致率 > State.TestSpec.MatchMin ? OkBrush : NgBrush;
            State.VmCnPoint.ColCn225    = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN225).一致率 > State.TestSpec.MatchMin ? OkBrush : NgBrush;
            State.VmCnPoint.ColCn226    = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.CN226).一致率 > State.TestSpec.MatchMin ? OkBrush : NgBrush;
            State.VmCnPoint.ColJp1      = TestConnector.ListCnSpecs2.Find(l => l.name == TestConnector.NAME2.JP1).一致率 > State.TestSpec.MatchMin ? OkBrush : NgBrush;



            RingCnTesting.IsActive = false;
            General.SetLight1(true);
            cnTesting = false;
            State.VmTestStatus.EnableButtonErrInfo = Visibility.Hidden;//コネクタチェックでエラーになるとエラー詳細ボタンが表示されてしまう!!!
        }
示例#22
0
        public void T07_Interrupt()
        {
            TestConnector c = new TestConnector();
            c.SetWait1Sec(true);
            TestClient t = new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetConnectablePort()));
            Thread.Sleep(500);
            c.Interrupt();

            Assert.IsTrue(c.Interrupted);
            Assert.IsFalse(c.Succeeded);
            Assert.IsFalse(t.Notified); //Clientには成功・失敗とも通知されないはず
        }
示例#23
0
        public void T06_NegotiationFailed()
        {
            TestConnector c = new TestConnector();
            c.SetError(true);
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetConnectablePort()));
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NegotiationFailed [{0}]", c.ErrorMessage));
        }