コード例 #1
0
            public void Resolve()
            {
                DiSetup.Tests();

                TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"));

                Assert.IsNotNull(client);
            }
コード例 #2
0
            public void DeleteAsyncNotFound()
            {
                DiSetup.Tests();

                var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.NotFound
                });

                TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"), handlerMock.Object);
                bool            result = client.DeleteAsync(1).GetAwaiter().GetResult();

                Assert.IsNotNull(result);
                Assert.AreEqual(false, result);
            }
コード例 #3
0
            public void GetAsync()
            {
                DiSetup.Tests();

                var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = this.getContent <ValueObject <string> >(new ValueObject <string>("Hello World")),
                });

                TypedTestClient      client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"), handlerMock.Object);
                ValueObject <string> result = client.GetAsync(1).GetAwaiter().GetResult();

                Assert.IsNotNull(result);
                Assert.AreEqual("Hello World", result.Value);
            }
コード例 #4
0
            public void CreateOrUpdateAsync()
            {
                DiSetup.Tests();

                var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.Accepted
                });

                var newItem = new ValueObject <string>("SomeThing");

                TypedTestClient client = DiHelper.GetService <TypedTestClient>(new Uri("http://baseUri"), handlerMock.Object);
                bool            result = client.CreateOrUpdateAsync(newItem).GetAwaiter().GetResult();

                Assert.IsNotNull(result);
                Assert.AreEqual(true, result);
            }