public void StoreNewUser_Test()
        {
            using (var db = ConnectionFactory.Open())
            {
                var service = new StoreNewUserService { ConnectionFactory = ConnectionFactory };

                var newUserRequest = new StoreNewUser
                {
                    UserName = "******",
                    Email = "*****@*****.**",
                    Password = "******"
                };
                var response = (StoreNewUserResponse)service.Execute(newUserRequest);

                var storedUser = db.First<User>("UserName = {0}", newUserRequest.UserName);
                Assert.That(storedUser.Id, Is.EqualTo(response.UserId));
                Assert.That(storedUser.Email, Is.EqualTo(newUserRequest.Email));
                Assert.That(storedUser.Password, Is.EqualTo(newUserRequest.Password));
            }
        }
Ejemplo n.º 2
0
		private static void DatabaseTest(IDbConnectionFactory connectionFactory)
		{
			ConfigureDatabase.Init(connectionFactory);

			var storeRequest = new StoreNewUser {
				Email = "new@email",
				Password = "******",
				UserName = "******"
			};

			var storeHandler = new StoreNewUserService { ConnectionFactory = connectionFactory };
			storeHandler.Execute(storeRequest);

			var getAllHandler = new GetAllUsersService { ConnectionFactory = connectionFactory };
			var response = (GetAllUsersResponse)getAllHandler.Execute(new GetAllUsers());

			var user = response.Users[0];

			System.Console.WriteLine("Stored and retrieved user: {0}, {1}, {2}",
				user.Id, user.UserName, user.Email);
		}