Exemplo n.º 1
0
        public void AngryPathTestMethod()
        {
            var mockHttp = new MockHttpMessageHandler();
            var sut      = new MagicResultHttpClient(null, SpecifiedBaseURL);

            sut.FetchMagicNumber();
        }
Exemplo n.º 2
0
        public void HappyPathTestMathod()
        {
            var mockHttp = new MockHttpMessageHandler();
            var sut      = new MagicResultHttpClient(mockHttp.ToHttpClient(), SpecifiedBaseURL);

            var assertion = mockHttp
                            .When(SpecifiedBaseURL)
                            .Respond("application/json", @"{ 'code': '4284-2033-7359-1983'}");

            var asyncTask = sut.FetchMagicNumber();

            asyncTask.Wait();

            Assert.AreEqual(1, mockHttp.GetMatchCount(assertion));
            Assert.AreEqual("4284-2033-7359-1983", asyncTask.Result.Code);
        }
Exemplo n.º 3
0
        public void HappyPathTestMethodAltData()
        {
            const string AltSpecifiedBaseURL = "https://mmymymymymymymymyyssssserver.com/answer";
            var          mockHttp            = new MockHttpMessageHandler();
            var          sut = new MagicResultHttpClient(mockHttp.ToHttpClient(), AltSpecifiedBaseURL);

            var assertion = mockHttp
                            .When(AltSpecifiedBaseURL)
                            .Respond("application/json", @"{ 'code': '4644-8749-1098-2675'}");

            var asyncTask = sut.FetchMagicNumber();

            asyncTask.Wait();

            Assert.AreEqual(1, mockHttp.GetMatchCount(assertion));
            Assert.AreEqual("4644-8749-1098-2675", asyncTask.Result.Code);
        }