示例#1
0
        public void Add_WorksCorrectly_WhenBothNumbersArePositive()
        {
            var expectedResult = 3d;

            var actualResult = _target.Add(1, 2);

            Assert.AreEqual(expectedResult, actualResult);
        }
示例#2
0
            public void ReturnsTheCorrectSum(int a, int b)
            {
                // Arrange
                var expected = a + b;

                // Act
                var actual = _uow.Add(a, b);

                // Assert
                Assert.Equal(expected, actual);
            }
        public void MarhService_Can_Do_Addition()
        {
            // Arrange
            MathService mathService = new MathService();

            // Act
            int result = mathService.Add(10, 5);

            // Assert
            Assert.AreEqual(expected: 15, actual: result);
        }
示例#4
0
        public void AddTest(decimal firstValue, decimal secondValue, decimal expected)
        {
            // Arrange
            IMathService math = new MathService();

            // Act
            decimal actual = math.Add(firstValue, secondValue);

            // Assert
            Assert.Equal(expected, actual);
        }
示例#5
0
        public void AddWithGivenInputsReturnsExpectedResults()
        {
            // Arrange
            var expected  = 4;
            var underTest = new MathService();

            // Act
            var actual = underTest.Add(2, 2);

            // Assert
            Assert.AreEqual(expected, actual);
        }
示例#6
0
        public void TestAdd()
        {
            //Arrange
            MathService s = new MathService();
            int         left, right, ExpectedResult;

            left           = 5;
            right          = 5;
            ExpectedResult = left + right;

            //Act
            int result = s.Add(left, right);

            //Assert
            Assert.AreEqual(result, ExpectedResult);
        }
示例#7
0
        static void Main(string[] args)
        {
            ////HttpChannel hc = new HttpChannel(0);
            //TcpChannel tc = new TcpChannel();
            //ChannelServices.RegisterChannel(tc, false);
            ////ChannelServices.RegisterChannel(hc, false);

            //RemotingConfiguration.RegisterWellKnownClientType(typeof(MathService), "TCP://localhost:1123/MS");

            ////RemotingConfiguration.RegisterActivatedClientType(typeof(MathService),"tcp://localhost:1123");

            RemotingConfiguration.Configure("Client.exe.config", false);
            MathService proxy = new MathService();

            Console.WriteLine(proxy.Add(10, 20));
            Console.WriteLine(proxy.Sub(20, 10));
            Console.WriteLine(proxy.GetCount());
        }
        public double parseProtocol(string line)
        {
            double firstValue  = double.MaxValue;
            double secondValue = double.MaxValue;
            double result      = double.MaxValue;

            string[] values = line.Split(':');
            if (values.Length != 3)
            {
                throw new Exception("No such a protocol exists");
            }
            try
            {
                firstValue  = Convert.ToDouble(values[1]);
                secondValue = Convert.ToDouble(values[2]);
            }
            catch (Exception)
            {
                throw new ArgumentException("Wrong arguments!!");
            }
            switch (values[0])
            {
            case "+":
                result = instance.Add(firstValue, secondValue);
                break;

            case "-":
                result = instance.Sub(firstValue, secondValue);
                break;

            case "/":
                result = instance.Div(firstValue, secondValue);
                break;

            case "*":
                result = instance.Mult(firstValue, secondValue);
                break;

            default:
                throw new ArgumentException("No such an operation");
            }
            return(result);
        }
    public static void Main()
    {
        MathService myService = new MathService();

        Console.WriteLine("\nThe sum of 10 and 10 is : {0}", myService.Add(10, 10));
    }
示例#10
0
 public void AddTest()
 {
     Assert.AreEqual(2, _mathService.Add(1, 1));
     Assert.AreEqual(3, _mathService.Add(1, 2));
     Assert.AreEqual(4, _mathService.Add(2, 2));
 }