Ejemplo n.º 1
0
        public void Login_WithEmptyBody_ReturnsBadRequest()
        {
            var authClient = ApiClientFactory.GetClient <AuthorizationClient>();
            var response   = authClient.LoginWithEmptyBody();

            Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest);
            Assert.AreEqual(response.Data.Title, "One or more validation errors occurred.");
            Assert.IsTrue(response.Data.Errors.ErrorsList.Contains("A non-empty request body is required."));
        }
Ejemplo n.º 2
0
        public void GetAllCategories()
        {
            var authClient = ApiClientFactory.GetClient<CategoriesClient>();
            var response = authClient.GetCategories();

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            Assert.IsTrue(response.Data.Categories.Count > 0);
            Assert.IsTrue(response.Data.Categories.Any(c => c.Name.Equals("Football")));
        }
Ejemplo n.º 3
0
        public void RegisterUser_WithEmptyFields_ReturnsBadRequest()
        {
            var user = new User
            {
                Login    = null,
                Password = null
            };

            var authClient = ApiClientFactory.GetClient <AuthorizationClient>(user);
            var response   = authClient.Register(user);

            Assert.IsNull(response.Data.Token);
            Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest);
            Assert.IsFalse(response.Data.Success);
            Assert.IsTrue(response.Data.Message.Equals("Incorrect login or password"));
        }
Ejemplo n.º 4
0
        public void RegisterExistingUser_ReturnsBadRequest()
        {
            var user = new User
            {
                Login    = "******",
                Password = "******"
            };

            var authClient = ApiClientFactory.GetClient <AuthorizationClient>(user);
            var response   = authClient.Register(user);

            Assert.IsNull(response.Data.Token);
            Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest);
            Assert.IsFalse(response.Data.Success);
            Assert.IsTrue(response.Data.Message.Equals("User already exists"));
        }
Ejemplo n.º 5
0
        public void Login_WithEmptyLogin(string email, string password)
        {
            var user = new User
            {
                Login    = email,
                Password = password
            };

            var authClient = ApiClientFactory.GetClient <AuthorizationClient>(user);
            var response   = authClient.Login <AuthResponse>(user);

            Assert.IsNull(response.Data.Token);
            Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest);
            Assert.IsFalse(response.Data.Success);
            Assert.IsTrue(response.Data.Message.Equals("Incorrect login or password"));
        }
Ejemplo n.º 6
0
        public void RegisterUser_WithRightCredentialsPassed_ReturnsToken()
        {
            var user = new User
            {
                Login    = DataGenerator.GenerateEmail(),
                Password = "******"
            };

            var authClient = ApiClientFactory.GetClient <AuthorizationClient>(user);
            var response   = authClient.Register(user);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
            Assert.IsTrue(response.Data.Message.Equals("Registred and generated token"));
            Assert.IsTrue(response.Data.Success);
            Assert.NotNull(response.Data.Token);
            Assert.IsTrue(response.Data.Token.Contains("Bearer"));
        }
Ejemplo n.º 7
0
        public void Login_WithRightCredentials_ReturnsUserToken()
        {
            var user = new User
            {
                Login    = "******",
                Password = "******"
            };

            var authClient = ApiClientFactory.GetClient <AuthorizationClient>(user);
            var response   = authClient.Login <AuthResponse>(user);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            Assert.IsTrue(response.Data.Message.Equals("New token has been generated"));
            Assert.IsTrue(response.Data.Success);
            Assert.NotNull(response.Data.Token);
            Assert.IsTrue(response.Data.Token.Contains("Bearer"));
        }
Ejemplo n.º 8
0
        public void RegisterNewUser_LoginWithCreatedUser_ReturnsTokenAndOkStatus()
        {
            var user = new User
            {
                Login    = DataGenerator.GenerateEmail(),
                Password = "******"
            };

            Console.WriteLine($"USER:\nlogin: {user.Login}\npass: {user.Password}");

            var authClient = ApiClientFactory.GetClient <AuthorizationClient>(user);

            authClient.Register(user);
            var response = authClient.Login <AuthResponse>(user);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            Assert.IsTrue(response.Data.Message.Equals("New token has been generated"));
            Assert.IsTrue(response.Data.Success);
            Assert.NotNull(response.Data.Token);
            Assert.IsTrue(response.Data.Token.Contains("Bearer"));
        }
Ejemplo n.º 9
0
 public DiagnosticsTester()
 {
     _client = ApiClientFactory.GetClient <IDiagnosticsClient>();
 }
Ejemplo n.º 10
0
        public DiagnosticsTester()
        {
            var config = TestConfig.Instance;

            _client = ApiClientFactory.GetClient <IDiagnosticsClient>(config.ApiUrl);
        }
Ejemplo n.º 11
0
        public void Login(User user)
        {
            var authClient = ApiClientFactory.GetClient <AuthorizationClient>(user);

            authClient.Login <AuthResponse>(user);
        }
Ejemplo n.º 12
0
 public ExampleTester()
 {
     _client = ApiClientFactory.GetClient <IExampleClient>();
 }
Ejemplo n.º 13
0
 public RepositoryBase(string serviceName = "DongboUser")
 {
     ServiceClient = ApiClientFactory.GetClient(serviceName);
 }
        public void GetPostClient()
        {
            var client = instance.GetClient();

            Assert.IsNotNull(client);
        }
Ejemplo n.º 15
0
        public ExampleTester()
        {
            var config = TestConfig.Instance;

            _client = ApiClientFactory.GetClient <IExampleClient>(config.ApiUrl);
        }