public void TestThatDataSourceGetAddCandidateKeys()
        {
            var oldToNewMetadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForTest(), GetConfigurationValuesMock());

            Assert.That(oldToNewMetadataRepository, Is.Not.Null);

            var dataSource = oldToNewMetadataRepository.DataSourceGet();

            Assert.That(dataSource, Is.Not.Null);
            Assert.That(dataSource.Tables, Is.Not.Null);

            var table = dataSource.Tables.Single(m => String.Compare(m.NameSource, "SAG", StringComparison.Ordinal) == 0);

            Assert.That(table, Is.Not.Null);
            Assert.That(table.CandidateKeys, Is.Not.Null);
            Assert.That(table.CandidateKeys, Is.Not.Empty);
            Assert.That(table.CandidateKeys.Count, Is.EqualTo(1));

            Assert.That(table.CandidateKeys.ElementAt(0).NameSource, Is.Not.Null);
            Assert.That(table.CandidateKeys.ElementAt(0).NameSource, Is.Not.Empty);
            Assert.That(table.CandidateKeys.ElementAt(0).NameSource, Is.EqualTo("PK_SAG"));
            Assert.That(table.CandidateKeys.ElementAt(0).NameTarget, Is.Not.Null);
            Assert.That(table.CandidateKeys.ElementAt(0).NameTarget, Is.Not.Empty);
            Assert.That(table.CandidateKeys.ElementAt(0).NameTarget, Is.EqualTo("PK_SAG"));
            Assert.That(table.CandidateKeys.ElementAt(0).Description, Is.Not.Null);
            Assert.That(table.CandidateKeys.ElementAt(0).Description, Is.Not.Empty);
            Assert.That(table.CandidateKeys.ElementAt(0).Description, Is.EqualTo("Primær nøgle på SAG"));
        }
 public void Then_Retrieved_Report_Is_Equivalent_To_SubmittedReport()
 {
     RepositoryTestHelper
     .AssertReportsAreEquivalent(
         SubmittedReport
         , submittedReports.Single());
 }
Ejemplo n.º 3
0
 public void Then_Retrieved_Report_Is_Equivalent_To_Created_Report()
 {
     RepositoryTestHelper
     .AssertReportsAreEquivalent(
         CreatedReport
         , _retrievedReport);
 }
Ejemplo n.º 4
0
        public void DeleteDtDeliveryResultTest(
            string no,
            string in_InsertNewDataSqlPath,
            string in_DeleteNewDataSqlPath,
            string expected_DataJsonPath,
            string expected_ExceptionType,
            string expected_ExceptionMessage,
            string remarks)
        {
            // 初期データ挿入
            RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath);

            var deletedResultData = _deliveryResultRepository.DeleteDtDeliveryResult(1);

            // データのjson化
            string readJson   = Utility.ObjectExtensions.ToStringJson(deletedResultData);
            string expectJson = null;

            if (File.Exists(expected_DataJsonPath))
            {
                expectJson = File.ReadAllText(expected_DataJsonPath);
            }

            // データの比較
            Assert.AreEqual(expectJson, readJson);

            // 後処理
            RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath);
        }
        public void TestThatDataSourceGetAddViews()
        {
            var oldToNewMetadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForTest(), GetConfigurationValuesMock());

            Assert.That(oldToNewMetadataRepository, Is.Not.Null);

            var dataSource = oldToNewMetadataRepository.DataSourceGet();

            Assert.That(dataSource, Is.Not.Null);
            Assert.That(dataSource.Views, Is.Not.Null);
            Assert.That(dataSource.Views.Count, Is.EqualTo(1));

            var view = dataSource.Views.First();

            Assert.That(view.NameSource, Is.Not.Null);
            Assert.That(view.NameSource, Is.Not.Empty);
            Assert.That(view.NameSource, Is.EqualTo("AV_VIEW1"));
            Assert.That(view.NameTarget, Is.Not.Null);
            Assert.That(view.NameTarget, Is.Not.Empty);
            Assert.That(view.NameTarget, Is.EqualTo("AV_VIEW1"));
            Assert.That(view.Description, Is.Not.Null);
            Assert.That(view.Description, Is.Not.Empty);
            Assert.That(view.Description, Is.EqualTo("Søgning af dokumenter efter sagsnummer og datointerval"));
            Assert.That(view.SqlQuery, Is.Not.Null);
            Assert.That(view.SqlQuery, Is.Not.Empty);
            Assert.That(view.SqlQuery, Is.EqualTo("CREATE TABLE f (snr VARCHAR(16), brevdatofra DATE, brevdatotil DATE)    INSERT INTO f (snr, brevdatofra, brevdatotil) VALUES (,,)    SELECT sag.sagsnr, sag.sagstitel, doktabel.dokumenttitel, doktabel.dato    FROM sag, doktabel    WHERE     sag.sagsnr LIKE (SELECT snr FROM f)+'%'  and    doktabel.sagsid=sag.sagsid and    doktabel.dato <  (SELECT brevdatotil FROM f) and    doktabel.dato > (SELECT brevdatofra FROM f)     DROP TABLE f"));
        }
        protected override void Given()
        {
            RepositoryTestHelper
            .ClearData();

            SUT = new SQLReportRepository(RepositoryTestHelper.ConnectionString);
        }
        public async Task AddCustomerAsync_WithValidCustomerModel_AddsNewRecordIntoDb()
        {
            // Arrange
            using (var context = await RepositoryTestHelper.GetInMemoryCustomerDbContext("AddTest1Db"))
            {
                var customerRepository = new CustomerRepository(context);
                var newCustomer        = new CustomerModel
                {
                    FirstName   = "Alan",
                    LastName    = "Turing",
                    DateOfBirth = new DateTime(1912, 6, 23)
                };

                var expectedResult = RepositoryTestHelper.GetMockCustomerData()
                                     .ToList();
                expectedResult.Add(new CustomerEntity
                {
                    Id          = 5,
                    FirstName   = newCustomer.FirstName,
                    LastName    = newCustomer.LastName,
                    DateOfBirth = newCustomer.DateOfBirth
                }
                                   );

                // Act
                await customerRepository.AddCustomerAsync(newCustomer);

                var result = await customerRepository.GetAllCustomersAsync();

                // Assert
                result.Should().BeEquivalentTo(expectedResult);
            }
        }
        public async Task UpdateCustomerAsync_WithExistingId_UpdatesRecordInDb()
        {
            // Arrange
            using (var context = await RepositoryTestHelper.GetInMemoryCustomerDbContext("UpdateTest1Db"))
            {
                var customerRepository = new CustomerRepository(context);
                var updatedCustomer    = new CustomerModel
                {
                    FirstName   = "Alan",
                    LastName    = "Turing",
                    DateOfBirth = new DateTime(1912, 6, 23)
                };

                var expectedResult = new CustomerEntity
                {
                    Id          = 1,
                    FirstName   = updatedCustomer.FirstName,
                    LastName    = updatedCustomer.LastName,
                    DateOfBirth = updatedCustomer.DateOfBirth
                };

                // Act
                await customerRepository.UpdateCustomerAsync(1, updatedCustomer);

                var result = await customerRepository.GetCustomersByNameAsync(firstName : updatedCustomer.FirstName, lastName : updatedCustomer.LastName);

                // Assert
                result.Should().BeEquivalentTo(expectedResult);
            }
        }
        public void TestThatDataSourceGetAddsFunctionalityToAField()
        {
            var oldToNewMetadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForTest(), GetConfigurationValuesMock());

            Assert.That(oldToNewMetadataRepository, Is.Not.Null);

            var dataSource = oldToNewMetadataRepository.DataSourceGet();

            Assert.That(dataSource, Is.Not.Null);
            Assert.That(dataSource.Tables, Is.Not.Null);

            var table = dataSource.Tables.Single(m => String.Compare(m.NameSource, "SAG", StringComparison.Ordinal) == 0);

            Assert.That(table, Is.Not.Null);
            Assert.That(table.Fields, Is.Not.Null);

            var field = table.Fields.Single(m => String.Compare(m.NameSource, "SagsID", StringComparison.Ordinal) == 0);

            Assert.That(field, Is.Not.Null);
            Assert.That(field.Functionality, Is.Not.Null);
            Assert.That(field.Functionality.OfType <IMarkFunctionality>(), Is.Not.Null);
            Assert.That(field.Functionality.OfType <IMarkFunctionality>().Count(), Is.EqualTo(1));
            Assert.That(field.Functionality.OfType <IMarkFunctionality>().First(), Is.Not.Null);
            Assert.That(field.Functionality.OfType <IMarkFunctionality>().First().Functionality, Is.Not.Null);
            Assert.That(field.Functionality.OfType <IMarkFunctionality>().First().Functionality, Is.Not.Empty);
            Assert.That(field.Functionality.OfType <IMarkFunctionality>().First().Functionality, Is.EqualTo("Sagsidentifikation"));
        }
        public void TestThatDataSourceGetAreMappingCodedValues()
        {
            var oldToNewMetadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForTest(), GetConfigurationValuesMock());

            Assert.That(oldToNewMetadataRepository, Is.Not.Null);

            var dataSource = oldToNewMetadataRepository.DataSourceGet();

            Assert.That(dataSource, Is.Not.Null);
            Assert.That(dataSource.Tables, Is.Not.Null);

            var table = dataSource.Tables.Single(m => String.Compare(m.NameSource, "SAGSBEH", StringComparison.Ordinal) == 0);

            Assert.That(table, Is.Not.Null);
            Assert.That(table.Fields, Is.Not.Null);

            var field = table.Fields.Single(m => String.Compare(m.NameSource, "Kontor", StringComparison.Ordinal) == 0);

            Assert.That(field, Is.Not.Null);
            Assert.That(field.DatatypeOfSource, Is.Not.Null);
            Assert.That(field.DatatypeOfSource, Is.EqualTo(typeof(int?)));
            Assert.That(field.LengthOfSource, Is.EqualTo(2));
            Assert.That(field.DatatypeOfTarget, Is.Not.Null);
            Assert.That(field.DatatypeOfTarget, Is.EqualTo(typeof(string)));
            Assert.That(field.LengthOfTarget, Is.EqualTo(9));
            Assert.That(field.Map, Is.Not.Null);
            Assert.That(field.Map, Is.TypeOf(typeof(StaticMap <int?, string>)));
        }
Ejemplo n.º 11
0
        public void UpdateDtDeliveryGroupStatusStartedTest(
            string no,
            string in_InsertNewDataSqlPath,
            string in_DeleteNewDataSqlPath,
            string expected_DataJsonPath,
            string expected_ExceptionType,
            string expected_ExceptionMessage,
            string remarks)
        {
            bool canUpdate = false;

            // 初期データ挿入
            if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath))
            {
                canUpdate = true;
            }

            string exceptionName    = "";
            string exceptionMessage = "";

            try
            {
                // データを更新する
                var updatedModel = _deliveryGroupRepository.UpdateDtDeliveryGroupStatusStarted(1);
                Assert.IsTrue((updatedModel != null) == canUpdate);

                if (updatedModel != null)
                {
                    // 比較に使用しないパラメータはnull or 固定値にする
                    updatedModel.UpdateDatetime = DateTime.Parse("2020/4/1 0:00:00");
                    updatedModel.RowVersion     = null;
                    updatedModel.MtDeliveryGroupStatus.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00");
                }

                // データのjson化
                string readJson   = Utility.ObjectExtensions.ToStringJson(updatedModel);
                string expectJson = null;
                if (File.Exists(expected_DataJsonPath))
                {
                    expectJson = File.ReadAllText(expected_DataJsonPath);
                }

                // データの比較
                Assert.AreEqual(expectJson, readJson);

                // TODO DBデータ内容をチェックする
            }
            catch (RmsCannotChangeDeliveredFileException e)
            {
                exceptionName    = e.GetType().FullName;
                exceptionMessage = e.Message;
            }
            // 例外発生チェック
            Assert.AreEqual(expected_ExceptionType, exceptionName);
            Assert.AreEqual(expected_ExceptionMessage, exceptionMessage);

            // 後処理
            RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath);
        }
Ejemplo n.º 12
0
        public void ReadDtDeviceTest(
            string no,
            string in_InsertNewDataSqlPath,
            string in_DeleteNewDataSqlPath,
            string expected_DataJsonPath,
            string expected_ExceptionType,
            string expected_ExceptionMessage,
            string remarks)
        {
            string uidOrEdgeId = null;

            // 初期データ挿入
            if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath))
            {
                // UidとEdgeID取得のため読み出す
                var readDevice = _deviceRepository.ReadDtDevice(2);
                Assert.IsNotNull(readDevice);

                switch (no)
                {
                case "1_001":
                    // UIDで検索する
                    uidOrEdgeId = readDevice.EquipmentUid;
                    break;

                case "1_002":
                    // エッジIDで検索する
                    uidOrEdgeId = readDevice.EdgeId.ToString();
                    break;

                case "1_003":
                    // 空文字
                    uidOrEdgeId = "";
                    break;

                default:
                    // null投入
                    break;
                }
            }

            // データを取得する(配信結果付き)
            var readModel = _deviceRepository.ReadDtDevice(uidOrEdgeId);

            // データのjson化
            string readJson   = Utility.ObjectExtensions.ToStringJson(readModel);
            string expectJson = null;

            if (File.Exists(expected_DataJsonPath))
            {
                expectJson = File.ReadAllText(expected_DataJsonPath);
            }

            // データの比較
            Assert.AreEqual(expectJson, readJson);

            // 後処理
            RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath);
        }
Ejemplo n.º 13
0
        public void TestThatDataGetFromTableThrowsArgumentNullExceptionIfTableIsNull()
        {
            var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest());

            Assert.That(oldToNewDataRepository, Is.Not.Null);

            Assert.Throws <ArgumentNullException>(() => oldToNewDataRepository.DataGetFromTable(null));
        }
Ejemplo n.º 14
0
 public void Then_All_History_For_That_Report_Is_Removed()
 {
     RepositoryTestHelper
     .GetAllAuditHistory()
     .Should()
     .NotContain(
         record => record.ReportId == RepositoryTestHelper.ReportTwoId);
 }
Ejemplo n.º 15
0
        public void TestThatGetDataQueryerThrowsNotSupportedException()
        {
            var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest());

            Assert.That(oldToNewDataRepository, Is.Not.Null);

            Assert.Throws <NotSupportedException>(() => oldToNewDataRepository.GetDataQueryer());
        }
        public void TestThatDataSourceGetAddContextDocuments()
        {
            var oldToNewMetadataRepository = new OldToNewMetadataRepository(RepositoryTestHelper.GetSourcePathForTest(), GetConfigurationValuesMock());

            Assert.That(oldToNewMetadataRepository, Is.Not.Null);

            var dataSource = oldToNewMetadataRepository.DataSourceGet();

            Assert.That(dataSource, Is.Not.Null);
            Assert.That(dataSource.ContextDocuments, Is.Not.Null);
            Assert.That(dataSource.ContextDocuments.Count, Is.EqualTo(2));

            var contextDocument = dataSource.ContextDocuments.First();

            Assert.That(contextDocument.Id, Is.EqualTo(1));
            Assert.That(contextDocument.NameSource, Is.Not.Null);
            Assert.That(contextDocument.NameSource, Is.Not.Empty);
            Assert.That(contextDocument.NameSource, Is.EqualTo("ER diagram"));
            Assert.That(contextDocument.NameTarget, Is.Not.Null);
            Assert.That(contextDocument.NameTarget, Is.Not.Empty);
            Assert.That(contextDocument.NameTarget, Is.EqualTo("ER diagram"));
            Assert.That(contextDocument.Description, Is.Null);
            Assert.That(contextDocument.DocumentDate, Is.EqualTo(DateTime.Now).Within(3).Seconds);
            Assert.That(contextDocument.DocumentDatePresicion, Is.EqualTo(DateTimePresicion.Month));
            Assert.That(contextDocument.DocumentAuthors, Is.Not.Null);
            Assert.That(contextDocument.DocumentAuthors.Count, Is.EqualTo(2));
            Assert.That(contextDocument.Categories, Is.Not.Null);
            Assert.That(contextDocument.Categories.Count, Is.EqualTo(2));
            Assert.That(contextDocument.Categories.Contains(ContextDocumentCategories.ArchivalTransformationInformation), Is.True);
            Assert.That(contextDocument.Categories.Contains(ContextDocumentCategories.InformationOther), Is.True);

            Assert.That(contextDocument.Reference, Is.Not.Null);
            Assert.That(contextDocument.Reference, Is.Not.Empty);

            var directoryName = Path.GetDirectoryName(contextDocument.Reference);

            Assert.That(directoryName, Is.Not.Null);
            Assert.That(directoryName, Is.Not.Empty);

// ReSharper disable AssignNullToNotNullAttribute
            var directoryInfo = new DirectoryInfo(directoryName);

// ReSharper restore AssignNullToNotNullAttribute
            Assert.That(directoryInfo, Is.Not.Null);
            Assert.That(directoryInfo.Exists, Is.True);

            var searchPattern = Path.GetFileName(contextDocument.Reference);

            Assert.That(searchPattern, Is.Not.Null);
            Assert.That(searchPattern, Is.Not.Empty);

// ReSharper disable AssignNullToNotNullAttribute
            var files = directoryInfo.GetFiles(searchPattern);

// ReSharper restore AssignNullToNotNullAttribute
            Assert.That(files, Is.Not.Null);
            Assert.That(files.Count(), Is.EqualTo(1));
        }
Ejemplo n.º 17
0
        protected override void Given()
        {
            RepositoryTestHelper.ClearData();

            SUT = new SQLReportRepository(new SqlConnection(RepositoryTestHelper.ConnectionString));

            BuildAndSaveAuditHistoryForReportOne();
            BuildAndSaveAuditHistoryForReportTwo();
        }
Ejemplo n.º 18
0
        public void Test_ProductionCalendarService_DeleteRecord()
        {
            RepositoryTestHelper.SetUpDeleteById <ProductionCalendarRecord, IProductionCalendarRepository>(_repositoryMock);

            var svc = new ProductionCalendarService(_repositoryFactoryMock.Object);

            svc.DeleteRecord(1);

            _repositoryMock.Verify(m => m.Delete(1), Times.Once());
        }
Ejemplo n.º 19
0
        public void TestThatDataGetForTargetTableThrowsArgumentNullExceptionIfDataSourceIsNull()
        {
            var fixture = new Fixture();

            var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest());

            Assert.That(oldToNewDataRepository, Is.Not.Null);

            Assert.Throws <ArgumentNullException>(() => oldToNewDataRepository.DataGetForTargetTable(fixture.CreateAnonymous <string>(), null));
        }
Ejemplo n.º 20
0
        public void DeleteDtDeliveryFileTest(
            string no,
            string in_InsertNewDataSqlPath,
            string in_DeleteNewDataSqlPath,
            string expected_DataJsonPath,
            string expected_ExceptionType,
            string expected_ExceptionMessage,
            string remarks)
        {
            byte[]         rowVersion = new byte[] { };
            DtDeliveryFile readModel  = null;
            bool           canDelete  = false;

            // 初期データ挿入
            if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath))
            {
                canDelete = true;

                // RowVersion取得のため読み出す
                readModel = _deliveryFileRepository.ReadDtDeliveryFile(2);
                Assert.IsNotNull(readModel);
                rowVersion = readModel.RowVersion;
            }

            string exceptionName    = "";
            string exceptionMessage = "";

            try
            {
                // データを削除する
                var deletedModel = _deliveryFileRepository.DeleteDtDeliveryFile(2, rowVersion);
                Assert.IsTrue((deletedModel != null) == canDelete);

                // 削除データを読み出せないことを確認する
                readModel = _deliveryFileRepository.ReadDtDeliveryFile(2);
                Assert.IsNull(readModel);

                // 子エンティティのデータも削除されたことを確認する
                var group = _deliveryGroupRepository.ReadDtDeliveryGroup(1);
                Assert.IsNull(group);
                var model = _deliveryModelRepository.ReadDtDeliveryModel(1);
                Assert.IsNull(model);
            }
            catch (RmsCannotChangeDeliveredFileException e)
            {
                exceptionName    = e.GetType().FullName;
                exceptionMessage = e.Message;
            }
            // 例外発生チェック
            Assert.AreEqual(expected_ExceptionType, exceptionName);
            Assert.AreEqual(expected_ExceptionMessage, exceptionMessage);

            // 後処理
            RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath);
        }
Ejemplo n.º 21
0
        public void ReadDeliveryIncludedDtDeliveryGroupTest(
            string no,
            string in_InsertNewDataSqlPath,
            string in_DeleteNewDataSqlPath,
            string expected_DataJsonPath,
            string expected_ExceptionType,
            string expected_ExceptionMessage,
            string remarks)
        {
            bool canRead = false;

            // 初期データ挿入
            if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath))
            {
                canRead = true;
            }

            // 配信グループデータを読み出す
            var readModel = _deliveryGroupRepository.ReadDeliveryIncludedDtDeliveryGroup(1);

            Assert.IsTrue((readModel != null) == canRead);

            if (readModel != null)
            {
                // 比較に使用しないパラメータはnull or 固定値にする
                readModel.RowVersion = null;
                readModel.DtDeliveryFile.RowVersion = null;
                readModel.DtDeliveryFile.MtInstallType.CreateDatetime      = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryFile.MtDeliveryFileType.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryFile.DtDeliveryModel.ToList()[0].MtEquipmentModel.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryResult.ToList()[0].DtDevice.EdgeId  = Guid.Empty;
                readModel.DtDeliveryResult.ToList()[0].DtDevice1.EdgeId = Guid.Empty;
                readModel.DtDeliveryResult.ToList()[0].DtDevice.MtConnectStatus.CreateDatetime   = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryResult.ToList()[0].DtDevice1.MtConnectStatus.CreateDatetime  = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryResult.ToList()[0].DtDevice.MtEquipmentModel.CreateDatetime  = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryResult.ToList()[0].DtDevice1.MtEquipmentModel.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryResult.ToList()[0].DtDevice.MtInstallType.CreateDatetime     = DateTime.Parse("2020/4/1 0:00:00");
                readModel.DtDeliveryResult.ToList()[0].DtDevice1.MtInstallType.CreateDatetime    = DateTime.Parse("2020/4/1 0:00:00");
            }

            // データのjson化
            string readJson   = Utility.ObjectExtensions.ToStringJson(readModel);
            string expectJson = null;

            if (File.Exists(expected_DataJsonPath))
            {
                expectJson = File.ReadAllText(expected_DataJsonPath);
            }

            // データの比較
            Assert.AreEqual(expectJson, readJson);

            // 後処理
            RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath);
        }
Ejemplo n.º 22
0
        public void TestThatCloneClonesDataRepository()
        {
            var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest());

            Assert.That(oldToNewDataRepository, Is.Not.Null);

            var clonedRepository = oldToNewDataRepository.Clone() as IDataRepository;

            Assert.That(clonedRepository, Is.Not.Null);
            Assert.That(clonedRepository, Is.Not.EqualTo(oldToNewDataRepository));
            Assert.That(clonedRepository, Is.TypeOf <OldToNewDataRepository>());
        }
        protected override void When()
        {
            _auditRecordDto = new AuditRecordDto
            {
                ReportId      = CreatedReport.Id,
                ReportingData = "Trump Dossier",
                UpdatedBy     = "Sergey & Oleg",
                UpdatedUtc    = RepositoryTestHelper.TrimDateTime(DateTime.UtcNow)
            };

            SUT.SaveAuditRecord(_auditRecordDto);
        }
Ejemplo n.º 24
0
        public void TestThatDataGetForTargetTableThrowsArgumentNullExceptionIfTargetTableNameIsEmpty()
        {
            var fixture = new Fixture();

            fixture.Customize <IDataSource>(e => e.FromFactory(() => MockRepository.GenerateMock <IDataSource>()));

            var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest());

            Assert.That(oldToNewDataRepository, Is.Not.Null);

            Assert.Throws <ArgumentNullException>(() => oldToNewDataRepository.DataGetForTargetTable(string.Empty, fixture.CreateAnonymous <IDataSource>()));
        }
Ejemplo n.º 25
0
        public void Test_ProductionCalendarService_GetAllRecords()
        {
            RepositoryTestHelper.SetUpGetAllWithSort(_repositoryMock, _testData);

            var svc     = new ProductionCalendarService(_repositoryFactoryMock.Object);
            var records = svc.GetAllRecords();

            _repositoryMock.Verify(m => m.GetAll(It.IsAny <Func <IQueryable <ProductionCalendarRecord>, IOrderedQueryable <ProductionCalendarRecord> > >()), Times.Once());

            Assert.Equal(7, records.Count());
            Assert.Equal(records[0].CalendarDate, new DateTime(2018, 3, 5));
            Assert.Equal(records[6].CalendarDate, new DateTime(2018, 3, 11));
        }
Ejemplo n.º 26
0
        public void Then_All_History_For_Other_Report_Remains_Intact()
        {
            RepositoryTestHelper
            .GetAllAuditHistory()
            .Should()
            .OnlyContain(
                record => record.ReportId == RepositoryTestHelper.ReportOneId);

            RepositoryTestHelper
            .GetAllAuditHistory()
            .Should()
            .HaveCount(
                5);
        }
Ejemplo n.º 27
0
        public void Then_Report_Is_Persisted_To_Underlying_Data_Store()
        {
            var reportPersistedToDb
                =
                    RepositoryTestHelper
                    .GetAllReports()
                    .Single(r => r.Id.Equals(RepositoryTestHelper.ReportOneId));

            RepositoryTestHelper
            .AssertReportsAreEquivalent(
                _reportCreatedViaRepository
                , reportPersistedToDb
                );
        }
        public async Task GetAllCustomersAsync_Returns_AllCustomersFromDb()
        {
            // Arrange
            using (var context = await RepositoryTestHelper.GetInMemoryCustomerDbContext("GetTest1Db"))
            {
                var customerRepository = new CustomerRepository(context);
                var expectedResult     = RepositoryTestHelper.GetMockCustomerData().ToList();

                //Act
                var result = await customerRepository.GetAllCustomersAsync();

                // Assert
                expectedResult.Should().BeEquivalentTo(result);
            }
        }
Ejemplo n.º 29
0
        protected override void Given()
        {
            base.Given();
            UpdatedReport = new ReportDto
            {
                Id                  = CreatedReport.Id,
                EmployerId          = CreatedReport.EmployerId,
                ReportingPeriod     = CreatedReport.ReportingPeriod,
                Submitted           = CreatedReport.Submitted,
                UpdatedUtc          = RepositoryTestHelper.TrimDateTime(DateTime.UtcNow.AddSeconds(-5)),
                AuditWindowStartUtc = RepositoryTestHelper.TrimDateTime(DateTime.UtcNow.AddSeconds(-10)),
                ReportingData       = "Wikileaks",
                UpdatedBy           = "Igor"
            };

            SUT.Update(UpdatedReport);
        }
Ejemplo n.º 30
0
        public void TestThatDataGetFromTableThrowsDeliveryEngineRepositoryExceptionIfTableIsNotFound()
        {
            var fixture = new Fixture();

            var oldToNewDataRepository = new OldToNewDataRepository(RepositoryTestHelper.GetSourcePathForTest());

            Assert.That(oldToNewDataRepository, Is.Not.Null);

            var tabelMock = MockRepository.GenerateMock <ITable>();

            tabelMock.Expect(m => m.NameSource)
            .Return(fixture.CreateAnonymous <string>())
            .Repeat.Any();
            fixture.Customize <ITable>(e => e.FromFactory(() => tabelMock));

            Assert.Throws <DeliveryEngineRepositoryException>(() => oldToNewDataRepository.DataGetFromTable(fixture.CreateAnonymous <ITable>()));
        }