Exemplo n.º 1
0
        public void CreateAdministratorTest()
        {
            Factory.CreateClient();
            IRepository <User>        users       = Factory.GetService <IRepository <User> >();
            IRepository <Credentials> credentials = Factory.GetService <IRepository <Credentials> >();

            Program.HandleCli(new string[5] {
                "administrator-create", "testName", TEST_EMAIL, TEST_LOGIN, TEST_PASSWORD
            });
            User[] usersTest = users.All();
            Assert.NotNull(users.First(x => x.Email == TEST_EMAIL && x.RoleId == UserRole.ADMINISTRATOR && x.StatusId == UserStatus.ACTIVE));
            Assert.NotNull(credentials.First(x => x.Login == TEST_LOGIN));
            Factory.DestroyDatabase();
        }
Exemplo n.º 2
0
        public async Task TestVerifyUser()
        {
            HttpClient client = Factory.CreateClient();

            HttpContent httpContent = new StringContent(JsonConvert.SerializeObject(new LoginRequest
            {
                Login    = FakeWebFactory <Startup> .TEST_LOGIN,
                Password = FakeWebFactory <Startup> .TEST_PASSWORD
            }));

            httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = await client.PostAsync("/api/security", httpContent);

            response.EnsureSuccessStatusCode();
            Assert.True(JsonConvert.DeserializeObject <Dictionary <string, string> >(await response.Content.ReadAsStringAsync())["token"].Length > 10);
            Factory.DestroyDatabase();
        }