コード例 #1
0
            public void IsNotNull()
            {
                DiSetup.RestDataServiceTests();
                DiSetup.InitializeRestEndpoints();

                IDataService dataService = DiHelper.GetService <IDataService>(new Uri("http://baseUri"), "someToken");

                Assert.IsNotNull(dataService);
                Assert.IsInstanceOfType(dataService, typeof(NET.efilnukefesin.Implementations.Services.DataService.RestDataService.RestDataService));
            }
コード例 #2
0
        //[TestMethod]
        public async Task AskSpecialEndpoint()
        {
            DiSetup.RestDataServiceTests();
            DiSetup.InitializeRestEndpoints();

            this.startLocalServer();

            IDataService dataService = DiHelper.GetService <IDataService>(this.localServerUri, this.getHttpClientHandler());

            var result = await dataService.GetAsync <ValueObject <bool> >("SpecialValueStore", "1", "Hello World");

            Assert.IsNotNull(result);
            Assert.AreEqual(true, result.Value);
        }
コード例 #3
0
        //[TestMethod]
        public async Task SimpleCallWithDataService()
        {
            DiSetup.RestDataServiceTests();
            DiSetup.InitializeRestEndpoints();

            this.startLocalServer();

            IDataService dataService = DiHelper.GetService <IDataService>(this.localServerUri, this.getHttpClientHandler());

            var result = await dataService.GetAllAsync <ValueObject <string> >("ValueStore");

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count());
        }
コード例 #4
0
        //[TestMethod]
        public async Task RegularGets()
        {
            DiSetup.RestDataServiceTests();
            DiSetup.InitializeRestEndpoints();

            this.startLocalServer();

            IDataService dataService = DiHelper.GetService <IDataService>(this.localServerUri, this.getHttpClientHandler());

            var result = await dataService.GetAllAsync <ValueObject <string> >("SpecialValueStore");

            var resultItem = await dataService.GetAsync <ValueObject <string> >("SpecialValueStore", result.ToList()[1].Id);  //TODO: check, why ids do not match

            Assert.IsNotNull(result);
            Assert.IsNotNull(resultItem);
            Assert.AreEqual(3, result.Count());
        }
コード例 #5
0
            public void GetAsync()
            {
                DiSetup.RestDataServiceTests();
                DiSetup.InitializeRestEndpoints();

                var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new StringContent(JsonConvert.SerializeObject(new SimpleResult <ValueObject <bool> >(new ValueObject <bool>(true)))),
                });

                IDataService dataService = DiHelper.GetService <IDataService>(new Uri("http://baseUri"), "someToken", handlerMock.Object);

                bool result = dataService.GetAsync <ValueObject <bool> >("TestResourceLocation").GetAwaiter().GetResult().Value;

                Assert.AreEqual(true, result);
            }
コード例 #6
0
            public void DeleteAsyncWithDelegate()
            {
                DiSetup.RestDataServiceTests();
                DiSetup.InitializeRestEndpoints();

                var handlerMock = this.messageHandlerMockFaker(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new StringContent(JsonConvert.SerializeObject(new SimpleResult <IEnumerable <ValueObject <bool> > >(new List <ValueObject <bool> >(new List <ValueObject <bool> >()
                    {
                        new ValueObject <bool>(true), new ValueObject <bool>(false), new ValueObject <bool>(true)
                    })))),
                });

                IDataService dataService = DiHelper.GetService <IDataService>(new Uri("http://localhost"), "someToken25", handlerMock.Object);

                bool result = dataService.DeleteAsync <ValueObject <bool> >("TestResourceLocation", x => x.Value.Equals(true)).GetAwaiter().GetResult();

                Assert.AreEqual(true, result);
            }