Ejemplo n.º 1
0
        public async Task ShouldGetPlainTextFromGetAllAsync()
        {
            var options = new YawatOptions(null)
            {
                MediaType = "text/plain"
            };
            var txt = (await SetupTeardown.HttpClientWithOptions.GetAsync($"{BaseRoute}", options)).AsString();

            Assert.Greater(txt.Length, 1);
        }
Ejemplo n.º 2
0
        public async Task ShouldGetObjectXmlFromGetAllAsync()
        {
            var options = new YawatOptions(typeof(XmlResponseData))
            {
                MediaType = "application/xml"
            };
            var toDoList = (await SetupTeardown.HttpClientWithOptions.GetAsync($"{BaseRoute}", options)).As <ArrayOfTodoItemDto>();

            Assert.AreNotEqual(toDoList.TodoItemDto.Length, 0);
        }
Ejemplo n.º 3
0
 public void Setup()
 {
     this.baseRoute = YawatSettings.Get("BasicAuthentication.BaseRoute");
     this.userName  = YawatSettings.Get("BasicAuthentication.UserName");
     this.password  = YawatSettings.Get("BasicAuthentication.Password");
     this.options   = new YawatOptions(typeof(JsonResponseData))
     {
         Authenticator = new Yawat.Authenticator.BasicAuthenticator(this.userName, this.password),
     };
 }
Ejemplo n.º 4
0
        public async Task ShouldGetXmlFromGetAllAsync()
        {
            var options = new YawatOptions(null)
            {
                MediaType = "application/xml"
            };
            var xml = (await SetupTeardown.HttpClientWithOptions.GetAsync($"{BaseRoute}", options)).AsString();

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            var nodeList = doc.SelectNodes("//TodoItemDto");

            Assert.AreEqual(nodeList.Count, 1);
        }
Ejemplo n.º 5
0
        public async Task Setup()
        {
            this.baseRoute = YawatSettings.Get("IdentityServer.BaseRoute");
            var identityServerUrl = YawatSettings.Get("IdentityServer.IdentityServerUrl");
            var clientId          = YawatSettings.Get("IdentityServer.ClientId");
            var clientSecret      = YawatSettings.Get("IdentityServer.ClientSecret");
            var scope             = YawatSettings.Get("IdentityServer.Scope");

            this.options = new YawatOptions(typeof(JsonResponseData))
            {
                Authenticator = new Yawat.Authenticator.IdentityServerAuthenticator(identityServerUrl, clientId, clientSecret, scope)
            };

            var success = await this.options.Authenticator.Setup();

            if (!success)
            {
                Console.WriteLine("IsAuthenticator.Setup() was not successful.");
                foreach (var error in this.options.Authenticator.GetErrors())
                {
                    Console.WriteLine($"    {error}");
                }
            }
        }