Beispiel #1
0
        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 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);
        }
        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 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 UsingAutoDataAttribute(int expectedNumber, EchoClass sut)
        {
            // Act
            int result = (int) sut.Echo(expectedNumber);

            // Assert
            result.Should().Be(expectedNumber);
        }