Exemplo n.º 1
0
        public void Create_Twice_Throws_Exception()
        {
            var pddb = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(PddbTestingInstance.GetFake());
            Assert.Throws <PersonalDataDBException>(() =>
            {
                pddb.CreateDatabase(PddbTestingInstance.GetFake());
            });
        }
Exemplo n.º 2
0
        public void Valid_Test()
        {
            var            builder = PddbTestingInstance.GetFake();
            PersonalDataDB pddb    = PersonalDataDB.Create(new InMemoryDataProvider());

            pddb.CreateDatabase(builder);
        }
Exemplo n.º 3
0
        public static PersonalDataDB GetPddbInstanceForTesting()
        {
            var            builder = PddbTestingInstance.GetFake();
            PersonalDataDB pddb    = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(builder);
            return(pddb);
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        public void Invalid_DataManager()
        {
            var builder = PddbTestingInstance.GetFake();

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

            Assert.Throws <InitializationException>(() =>
            {
                pddb.CreateDatabase(builder);
            });
        }
Exemplo n.º 9
0
        public void Create()
        {
            var builder = new DefaultInitializationDataProvider()
                          .UseDataManager(new DataManagerInitialization()
            {
                Name                           = "SomeCompany",
                Address                        = "Street 1",
                Email                          = "*****@*****.**",
                Phone                          = "123456789",
                RegistrationNumber             = "123",
                PersonalDataRegistrationNumber = "456"
            })
                          .UseAdministrator(new AdministratorInitialization()
            {
                FullName            = "Karel Admin",
                Phone               = "123456789",
                Email               = "*****@*****.**",
                OfficeNumber        = "123",
                InternalPhoneNumber = "456",
                Supervisor          = "Charles Supervisor"
            })
                          .UseConfiguration(new ConfigurationInitialization()
            {
                AllowPurposeChoiceOnAgreementCreation = false
            })
                          .UseSchema((b) =>
            {
                b.AddTable("Persons", tb =>
                {
                    tb.Name        = "Persons table";
                    tb.Description = "Contains personal data of people";
                    tb.AddColumn("FullName", ColumnType.String, false);
                    tb.AddColumn("Phone", ColumnType.String, true);
                });
                b.AddTable("GPSPositions", tb =>
                {
                    tb.Name        = "GPS positions";
                    tb.Description = "Tracking data of people";
                    tb.AddForeignKeyColumn("PersonID", "Persons", false);
                    tb.AddColumn("Latitude", ColumnType.Double, false);
                    tb.AddColumn("Longitude", ColumnType.Double, false);
                });
            });

            var pddb = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(builder);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        public void Create()
        {
            var pddb = new PersonalDataDB(new InMemoryDataProvider());

            pddb.CreateDatabase(PddbTestingInstance.GetFake());
        }