public void Insert_Invalid_DataManager() { var pddb = PddbTestingInstance.GetPddbInstanceForTesting(); object adminID = pddb.ListAdministrators().Single().ID !; Assert.Throws <ValidationException>(() => { pddb.InsertDataManager(adminID, new DataManagerInsertModel("", "", "", "", null, null)); }); Assert.Throws <PersonalDataDBException>(() => { pddb.InsertDataManager(Guid.NewGuid(), new DataManagerInsertModel("a", "b", "c", "d", null, null)); }); }
public void Insert_DataManager() { var pddb = PddbTestingInstance.GetPddbInstanceForTesting(); object adminID = pddb.ListAdministrators().Single().ID !; object newDataManagerId = pddb.InsertDataManager(adminID, new DataManagerInsertModel("Another company", "another address", "*****@*****.**", "123456789", "999", "666")); IEnumerable <IDataManager> dataManagers = pddb.ListDataManagers(); Assert.Equal(2, dataManagers.Count()); Assert.Single(dataManagers, d => d.ID !.Equals(newDataManagerId)); IEnumerable <IAdministratorLog> adminLog = pddb.ListAdministratorLogs(); Assert.Single(adminLog); }
public void Insert_Administrator() { PersonalDataDB pddb = PddbTestingInstance.GetPddbInstanceForTesting(); IAdministrator admin = pddb.ListAdministrators().Single(); object newAdminId = pddb.InsertAdministrator(admin.ID, new AdministratorInsertModel("Karel Varel", "123456789", "*****@*****.**", null, null, null)); var administrators = pddb.ListAdministrators(); Assert.Equal(2, administrators.Count()); Assert.Contains(administrators, t => t.ID.Equals(newAdminId)); IAdministrator newAdmin = administrators.FirstOrDefault(t => t.ID.Equals(newAdminId)); Assert.Equal("Karel Varel", newAdmin.FullName); Assert.Equal("123456789", newAdmin.Phone); Assert.Equal("*****@*****.**", newAdmin.Email); }
public void Update_Administrator() { PersonalDataDB pddb = PddbTestingInstance.GetPddbInstanceForTesting(); IAdministrator admin = pddb.ListAdministrators().Single(); pddb.UpdateAdministrator(admin.ID, new AdministratorUpdateModel(admin.ID, "999", "*****@*****.**", "666", "satan", "super")); var administrators = pddb.ListAdministrators(); Assert.Single(administrators); admin = pddb.ListAdministrators().Single(); Assert.Equal("Karel Admin", admin.FullName); Assert.Equal("999", admin.Phone); Assert.Equal("*****@*****.**", admin.Email); Assert.Equal("666", admin.OfficeNumber); Assert.Equal("satan", admin.InternalPhoneNumber); Assert.Equal("super", admin.Supervisor); }
public void Update_User() { PersonalDataDB pddb = PddbTestingInstance.GetPddbInstanceForTesting(); var users = pddb.ListUsers(); Assert.Empty(users); IAdministrator admin = pddb.ListAdministrators().Single(); object newId = pddb.InsertUser(admin.ID, new UserInsertModel("Karel", "123", "*****@*****.**", "5", "6", "Some Supervisor")); pddb.UpdateUser(admin.ID, new UserUpdateModel(newId, "99999", "*****@*****.**", null, null, null)); var insertedUser = pddb.ListUsers().Single(); Assert.Equal("Karel", insertedUser.FullName); Assert.Equal("99999", insertedUser.Phone); Assert.Equal("*****@*****.**", insertedUser.Email); Assert.Null(insertedUser.OfficeNumber); Assert.Null(insertedUser.InternalPhoneNumber); Assert.Null(insertedUser.Supervisor); }
public void List_And_Insert_Users() { PersonalDataDB pddb = PddbTestingInstance.GetPddbInstanceForTesting(); var users = pddb.ListUsers(); Assert.Empty(users); IAdministrator admin = pddb.ListAdministrators().Single(); object newId = pddb.InsertUser(admin.ID, new UserInsertModel("Karel", "123", "*****@*****.**", "5", "6", "Some Supervisor")); users = pddb.ListUsers(); Assert.Single(users); Assert.Equal(newId, users.Single().ID); var insertedUser = users.Single(); Assert.Equal("Karel", insertedUser.FullName); Assert.Equal("123", insertedUser.Phone); Assert.Equal("*****@*****.**", insertedUser.Email); Assert.Equal("5", insertedUser.OfficeNumber); Assert.Equal("6", insertedUser.InternalPhoneNumber); Assert.Equal("Some Supervisor", insertedUser.Supervisor); }