I am going nuts here! I am trying to figure out that why my UserRepository.Save method is inserting two records for the same user.
Here is the code:
[TestFixture]
public class foo
{
private IUserRepository _userRepository;
private IRoleRepository _roleRepository;
private User _user;
[SetUp]
public void ini()
{
EStudy.Domain.Model.Configuration.StructureMapConfiguration.Configure();
_userRepository = ObjectFactory.GetInstance<IUserRepository>();
_roleRepository = ObjectFactory.GetInstance<IRoleRepository>();
_user = new User()
{
FirstName = "Mohammad",
LastName = "Azam",
UserName = "azamsharp",
Password = "password",
Active = true,
DateCreated = DateTime.Now,
DateModified = DateTime.Now,
Email = "[email protected]",
};
}
[Test]
public void boo()
{
_user.AddRole(_roleRepository.GetByName("Student"));
_userRepository.Save(_user);
Assert.IsTrue(_user.UserId > 0);
}
}
updated: The simplest test that is failing. The test boo fails.