static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("usage: echoclient input-string"); return; } EchoClass proxy = new EchoClass(); try { Console.WriteLine(proxy.Echo(args[0])); } catch (Exception e) { if (e is WebException) { // contact UDDI server for current location Console.WriteLine("Contacting UDDI server for current location..."); string newLoc = InvocationPattern.FindCurrentLocation((WebException)e, "EchoServiceUddiBindingKey", "UddiServerLocation"); if (newLoc != "") { proxy.Url = newLoc; Console.WriteLine(proxy.Echo(args[0])); // if it succeeds, update local configuration file Console.WriteLine("Updating client configuration..."); InvocationPattern.UpdateLocalConfiguration("echoclient.exe.config", "EchoServiceLocation", newLoc); return; } } Console.WriteLine(e.Message); } }
public void AutoGenerateIntValues() { EchoClass sut = new EchoClass(); Fixture fixture = new Fixture(); int expectedNumber = fixture.Create<int>(); // Act int result = (int) sut.Echo(expectedNumber); // Assert result.Should().Be(expectedNumber); }
public void AutoGenerateComplexTypes() { EchoClass sut = new EchoClass(); Fixture fixture = new Fixture(); DataClass expectedDataClass = fixture.Create<DataClass>(); // Act DataClass resultDataClass = (DataClass)sut.Echo(expectedDataClass); // Assert resultDataClass.SomeStringField.Should().NotBeNullOrEmpty(); resultDataClass.SomeStringField.Should().Be(expectedDataClass.SomeStringField); resultDataClass.WhoCaresWhatIntValue.Should().Be(expectedDataClass.WhoCaresWhatIntValue); }
void ResentContent(ref HelperClass helper, ref ControllerWorker controller, ref string bufS) { EchoClass ec = controller._GetNextContent(); while (ec.type != EchoClass.EchoType.End) { switch (ec.type) { case EchoClass.EchoType.String: bufS += (string)ec.param; break; case EchoClass.EchoType.Layout: ResentLayout(ref helper, ref controller, ref bufS, (string)ec.param, false); break; } //while (bufS.Length > 16000) { // byte[] buf = Encoding.UTF8.GetBytes(bufS.Substring(0, 16000)); // bufS = bufS.Remove(0, 16000); // helper.Context.Response.OutputStream.Write(buf, 0, buf.Length); //} ec = controller._GetNextContent(); } }
void ResentLayout(ref HelperClass helper, ref ControllerWorker controller, ref string bufS, string layoutName, bool content) { LayoutWorker layout = GetLayout(layoutName); GetStaticPlugins(layout, ref helper); layout._Work(helper); helper.GetData(layout._GetHelper()); EchoClass ec = layout._GetNextContent(); while (ec.type != EchoClass.EchoType.End) { switch (ec.type) { case EchoClass.EchoType.String: bufS += (string)ec.param; break; case EchoClass.EchoType.Layout: ResentLayout(ref helper, ref controller, ref bufS, (string)ec.param, content); break; case EchoClass.EchoType.Content: if (content) { ResentContent(ref helper, ref controller, ref bufS); } break; } //while (bufS.Length > 16000) { // byte[] buf = Encoding.UTF8.GetBytes(bufS.Substring(0, 16000)); // bufS = bufS.Remove(0, 16000); // helper.Context.Response.OutputStream.Write(buf, 0, buf.Length); //} ec = layout._GetNextContent(); } }
public void AutoGenerateStringValues() { EchoClass sut = new EchoClass(); Fixture fixture = new Fixture(); string expectedString = fixture.Create<string>(); // Act string result = (string)sut.Echo(expectedString); // Assert result.Should().Be(expectedString); }
public void UsingAutoDataAttribute(int expectedNumber, EchoClass sut) { // Act int result = (int) sut.Echo(expectedNumber); // Assert result.Should().Be(expectedNumber); }
public void TestEchoClass() { var echoClass = new EchoClass(); Assert.AreEqual(0, echoClass.CreateAndTestSocket()); }