public void Valid_Test()
        {
            var            builder = PddbTestingInstance.GetFake();
            PersonalDataDB pddb    = PersonalDataDB.Create(new InMemoryDataProvider());

            pddb.CreateDatabase(builder);
        }
Exemple #2
0
        public void Create_IfNotExist_Twice()
        {
            var pddb = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabaseIfNotExist(PddbTestingInstance.GetFake());
            pddb.CreateDatabaseIfNotExist(PddbTestingInstance.GetFake());
        }
        public static PersonalDataDB GetPddbInstanceForTesting()
        {
            var            builder = PddbTestingInstance.GetFake();
            PersonalDataDB pddb    = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(builder);
            return(pddb);
        }
        public void Missing_Schema_Throws_Exception()
        {
            var builder = PddbTestingInstance.GetFake();

            builder.Schema = null;
            PersonalDataDB pddb = PersonalDataDB.Create(new InMemoryDataProvider());

            Assert.Throws <InitializationException>(() => pddb.CreateDatabase(builder));
        }
Exemple #5
0
        public void Create_Twice_Throws_Exception()
        {
            var pddb = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(PddbTestingInstance.GetFake());
            Assert.Throws <PersonalDataDBException>(() =>
            {
                pddb.CreateDatabase(PddbTestingInstance.GetFake());
            });
        }
        public void Invalid_Admin_Throws_Exception()
        {
            var builder = PddbTestingInstance.GetFake();

            ((AdministratorMock)builder.Administrator !).FullName = "";

            PersonalDataDB pddb = PersonalDataDB.Create(new InMemoryDataProvider());

            Assert.Throws <InitializationException>(() => pddb.CreateDatabase(builder));
        }
        public void Invalid_Schema_No_Tables_Throws_Exception()
        {
            var builder = PddbTestingInstance.GetFake();

            ((SchemaMock)builder.Schema !).TableMocks = new List <TableDefinitionMock>();

            PersonalDataDB pddb = PersonalDataDB.Create(new InMemoryDataProvider());

            Assert.Throws <InitializationException>(() => pddb.CreateDatabase(builder));
        }
        public void Invalid_Schema_Duplicate_Columns_Throws_Exception()
        {
            var        builder = PddbTestingInstance.GetFake();
            SchemaMock sm      = ((SchemaMock)builder.Schema !);

            sm.TableMocks[1].ColumnMocks[0].ID = sm.TableMocks[1].ColumnMocks[1].ID;

            PersonalDataDB pddb = PersonalDataDB.Create(new InMemoryDataProvider());

            Assert.Throws <InitializationException>(() => pddb.CreateDatabase(builder));
        }
        public void Invalid_DataManager()
        {
            var builder = PddbTestingInstance.GetFake();

            ((DataManagerMock)builder.DataManager !).Name = "";
            PersonalDataDB pddb = PersonalDataDB.Create(new InMemoryDataProvider());

            Assert.Throws <InitializationException>(() =>
            {
                pddb.CreateDatabase(builder);
            });
        }
        public void List_DataManagers()
        {
            var            builder = PddbTestingInstance.GetFake();
            PersonalDataDB pddb    = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(builder);

            IEnumerable <IDataManager> dataManagers = pddb.ListDataManagers();

            Assert.NotEmpty(dataManagers);
            Assert.Single(dataManagers);

            IDataManager dataManager = dataManagers.Single();

            Assert.Equal(builder.DataManager !.Name, dataManager.Name);
            Assert.Equal(builder.DataManager !.Phone, dataManager.Phone);
            Assert.Equal(builder.DataManager !.Email, dataManager.Email);
            Assert.Equal(builder.DataManager !.RegistrationNumber, dataManager.RegistrationNumber);
            Assert.Equal(builder.DataManager !.PersonalDataRegistrationNumber, dataManager.PersonalDataRegistrationNumber);
        }
        public void List_Administrators()
        {
            var            builder = PddbTestingInstance.GetFake();
            PersonalDataDB pddb    = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(builder);

            IEnumerable <IAdministrator> administrators = pddb.ListAdministrators();

            Assert.NotEmpty(administrators);
            Assert.Single(administrators);

            IAdministrator administrator = administrators.Single();

            Assert.Equal(builder.Administrator !.FullName, administrator.FullName);
            Assert.Equal(builder.Administrator !.Email, administrator.Email);
            Assert.Equal(builder.Administrator !.InternalPhoneNumber, administrator.InternalPhoneNumber);
            Assert.Equal(builder.Administrator !.OfficeNumber, administrator.OfficeNumber);
            Assert.Equal(builder.Administrator !.Phone, administrator.Phone);
            Assert.Equal(builder.Administrator !.Supervisor, administrator.Supervisor);
        }