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)); }
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)); }
private void CreateAndRunComputer(long[] instructions) { _computer = CreateComputer(instructions); if (_connector == null) { _connector = new TestConnector(AllOutput); } _computer.Connect(_connector); State = _computer.Run(); LastOutput = _connector.LastInput; }
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(); }
public void CreateConnectionReceivesNonNullConfiguration() { // Arrange var connector = new TestConnector(); var config = new object(); // Act connector.GetConnection(config); // Assert connector.LastReceived.Should().Be((1, config)); }
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(); }
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); }
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)); }
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); }
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には成功・失敗とも通知されないはず }
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); } }
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(); }
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); } }
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;//コネクタチェックでエラーになるとエラー詳細ボタンが表示されてしまう!!! }
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)); }