Ejemplo n.º 1
0
        public static async Task <Result <int> > StubSupervisor()
        {
            SupervisorGateway supervisorGateway = new SupervisorGateway(ConnectionString);
            Result <int>      user = await StubUser();

            string lastName  = TestHelpers.RandomTestName();
            string firstName = TestHelpers.RandomTestName();
            string phone     = TestHelpers.RandomPhone();

            Result <int> super = await supervisorGateway.Create(user.Content, lastName, firstName, phone);

            return(super);
        }
Ejemplo n.º 2
0
        public async Task can_create_edit_update_and_delete_a_supervisor()
        {
            SupervisorGateway sut         = new SupervisorGateway(TestHelpers.ConnectionString);
            UserGateway       userGateway = new UserGateway(TestHelpers.ConnectionString);

            string lastName  = TestHelpers.RandomTestName();
            string firstName = TestHelpers.RandomTestName();
            string phone     = TestHelpers.RandomPhone();
            string email     = TestHelpers.RandomEmail();
            var    password  = Guid.NewGuid().ToByteArray();


            var userResult = await userGateway.CreatePasswordUser(email, password);

            int userId = userResult.Content;
            //Create
            var result = await sut.Create(userId, lastName, firstName, phone);

            Assert.That(result.Status, Is.EqualTo(Status.Created));

            int superId = result.Content;

            Result <SupervisorData> supervisor;
            {
                supervisor = await sut.Find(superId);

                CheckSupervisor(supervisor, lastName, firstName, phone, email);
            }
            {
                lastName  = TestHelpers.RandomTestName();
                firstName = TestHelpers.RandomTestName();
                email     = TestHelpers.RandomEmail();

                await sut.Update(superId, email, lastName, firstName, phone);

                supervisor = await sut.Find(superId);

                CheckSupervisor(supervisor, lastName, firstName, phone, email);
            }

            //TODO
            //Work on supervisor Delete
            //{
            //    Result r = await sut.Delete(superId);
            //    Assert.That(r.Status, Is.EqualTo(Status.Ok));
            //    supervisor = await sut.Find(superId);
            //    Assert.That(supervisor.Status, Is.EqualTo(Status.NotFound));
            //}
        }