public void Get_TypesOfAssociations_Correct() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); repo.GetStudyRepo().Create(new StudyEntity { Id = 10, Name = "name", Description = "desc" }); repo.GetUserRepo().Create(new UserEntity() { Id = 10, FirstName = "Mathias", LastName = "Pedersen" }); repo.GetUserRepo().Create(new UserEntity() { Id = 11, FirstName = "John", LastName = "Doe" }); repo.GetStudyRoleRepo().Create(new StudyRoleEntity() { Id = 5, Name = "RoleWithId5" }); repo.GetStudyRoleRepo().Create(new StudyRoleEntity() { Id = 6, Name = "RoleWithId6" }); repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity() { Study_Id = 10, Id = 10, StudyRole_Id = 5 }); repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity() { Study_Id = 10, Id = 10, StudyRole_Id = 6 }); repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity() { Study_Id = 10, Id = 11, StudyRole_Id = 5 }); // Act var model = bll.Get(10); // Assert var list = model.Persons.Where(pair => pair.Key.Id == 10).Select(pair => pair.Value).Single(); Assert.AreEqual(2, list.Count); }
public void Get_NoSuchId_ThrowIndexOutOfRangeException() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); // Act var model = bll.Get(10); }
public void Add_ModelNull_ThrowNullException() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); // Act bll.Add(null); }
public void Add_ModelIdOutofRange_ThrowsArgumentException() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); var model = new UserModel { Id = -1 }; // Act bll.Add(model); }
public void Add_ModelNotNull_Successful() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); var model = new UserModel(); var precount = repo.GetUserRepo().GetAll().Count(); // Act bll.Add(model); // Assert Assert.AreEqual(repo.GetUserRepo().GetAll().Count(), precount + 1); }
public void GetTasks_checkTaskInfo_Correct() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new TaskBLL(repo); repo.GetTaskRepo().Create(new TaskEntity() { }); // Act // Assert }
public void Get_NumberOfAssociations_Correct() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); repo.GetStudyRepo().Create(new StudyEntity { Id = 10, Name = "name", Description = "desc" }); repo.GetUserRepo().Create(new UserEntity() { Id = 10, FirstName = "Mathias", LastName = "Pedersen" }); repo.GetUserRepo().Create(new UserEntity() { Id = 11, FirstName = "John", LastName = "Doe" }); repo.GetStudyRoleRepo().Create(new StudyRoleEntity() { Id = 5, Name = "RoleWithId5" }); repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity() { Study_Id = 10, Id = 10, StudyRole_Id = 5 }); repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity() { Study_Id = 10, Id = 11, StudyRole_Id = 5 }); var count = repo.GetUserStudyRelationRepo().GetAll().Count(r => r.Study_Id == 10); // Act var model = bll.Get(10); // Assert Assert.AreEqual(count, model.Persons.Count); }
public void AssociateUserTostudy_NonexistantRoleId_ThrowArgumentOutOfRangeException() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); repo.GetUserRepo().Create(new UserEntity() { Id = 10 }); repo.GetStudyRepo().Create(new StudyEntity() { Id = 15 }); // Act bll.AssociateUserToStudy(10, 15, 5); }
public void Remove_GoodId_Successful() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); repo.GetStudyRepo().Create(new StudyEntity { Id = 13 }); var count = repo.GetStudyRepo().GetAll().Count(); // Act bll.Remove(13); // Assert Assert.AreEqual(count - 1, repo.GetStudyRepo().GetAll().Count()); }
public void AddNew_GoodInput_Successful() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); var model = new StudyOverviewModel { Id = 10, Name = "name", Description = "desc" }; var count = repo.GetStudyRepo().GetAll().Count(); // Act bll.AddNew(model); // Assert Assert.AreEqual(count + 1, repo.GetStudyRepo().GetAll().Count()); }
public void Get__Successful() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); var model = new StudyOverviewModel { Id = 10, Name = "name", Description = "desc" }; var count = repo.GetStudyRepo().GetAll().Count(); // Act var list = bll.Get(); // Assert Assert.AreEqual(count, list.Count); }
public void UnassociateUserToStudy_GoodInput_Success() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); repo.GetUserStudyRelationRepo().Create(new UserStudyRelationEntity { Study_Id = 15, StudyRole_Id = 2, Id = 10 }); var count = repo.GetUserStudyRelationRepo().GetAll().Count(); // Act bll.UnassociateUserToStudy(10, 15); // Assert Assert.AreEqual(count - 1, repo.GetUserStudyRelationRepo().GetAll().Count()); }
public void AssociateUserToStudy_GoodInput_Success() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); repo.GetUserRepo().Create(new UserEntity() { }); // Act bll.AssociateUserToStudy(10, 15, 5); // Assert var storedDto = repo.GetUserStudyRelationRepo().Read(10, 15); Assert.AreEqual(storedDto.Id, 10); Assert.AreEqual(storedDto.Study_Id, 15); Assert.AreEqual(storedDto.StudyRole_Id, 5); }
public void Get_ElementExists_Successful() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new UserBLL(repo); repo.GetUserRepo().Create(new UserEntity { Id = 10, FirstName = "Mathias", LastName = "Pedersen" }); // Act var model = bll.Get(10); // Assert Assert.AreEqual(model.Id, 10); Assert.AreEqual(model.FirstName, "Mathias"); Assert.AreEqual(model.LastName, "Pedersen"); }
public void Get_StudyTableDataExists_Successful() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); repo.GetStudyRepo().Create(new StudyEntity { Id = 10, Name = "name", Description = "desc" }); // Act var model = bll.Get(10); // Assert Assert.AreEqual(10, model.Id); Assert.AreEqual("name", model.Name); Assert.AreEqual("desc", model.Description); }
public void Get_AssociatedStages_Successful() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); repo.GetStudyRepo().Create(new StudyEntity { Id = 10, Name = "name", Description = "desc" }); var bcount = repo.GetStageRepo().GetAll().Count(d => d.Study_Id == 10); repo.GetStageRepo().Create(new StageEntity { Study_Id = 10, Name = "Stage1", Id = 15 }); repo.GetStageRepo().Create(new StageEntity { Study_Id = 10, Name = "Stage2", Id = 16 }); // Act var model = bll.Get(10); // Assert var stage = model.Stages.Find(s => s.Id == 15); Assert.AreEqual(bcount + 2, model.Stages.Count); Assert.IsNotNull(stage); Assert.AreEqual("Stage1", stage.Name); }
public void AddStage_GoodInput_StageAdded() { // Arrange var repo = new RepositoryFactoryMemory(); var bll = new StudyBLL(repo); }