public override void Given() { base.Given(); var user = new User("ValidUserName", "ValidPassword", string.Empty, "ValidGroupId"); UserRepository.Setup(u => u.GetUserFromUsername("ValidUserName")).Returns(user); TicketGeneration.Setup(t => t.GetTicket(user)).Returns("Ticket"); }
public virtual User GetUserFromUsername(string username) { var user = new User(string.Empty,string.Empty,string.Empty); if(username==null) return user; using (var connection = new SqlConnection(_connectionString)) { var parameter = new SqlParameter() { ParameterName = "@userName", Value = username }; var command = new SqlCommand("SELECT UserName" +" ,[Password]" +" ,ActiveDirectoryName" +" FROM [dbo].[Users]" + " WHERE UserName = @userName;" , connection); command.Parameters.Add(parameter); using (command) { connection.Open(); var reader = command.ExecuteReader(); if (reader != null && reader.HasRows) { reader.Read(); user.Username = reader["UserName"].ToString(); user.Password = reader["Password"].ToString(); user.ActiveDirectoryName = reader["ActiveDirectoryName"].ToString(); } connection.Close(); } } return user; }
public override void Given() { base.Given(); User = new User("ValidUsername", "ValidPassword", "ValidADName", "ValidGroupId"); }
public override void Given() { MockUserRepository = new Mock<UserRepository>(); User = new User(); Login = new Login(MockUserRepository.Object); }
public override void When() { var validUser = new User("Valid", "Valid", @"TELOGICAL\VBalasubramanian", "ValidGroupId"); Ticket = TicketGeneration.GetTicket(validUser); }
public override void When() { var inValidUser = new User("Valid", "Valid", "", "ValidGroupId"); Ticket = TicketGeneration.GetTicket(inValidUser); }