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 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); }
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); }
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); }
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); }
public void ReadStartableDtDeliveryGroupTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { // 初期データ挿入 RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath); // 配信グループデータを読み出す var readModels = _deliveryGroupRepository.ReadStartableDtDeliveryGroup().ToList(); if (readModels.Count != 0) { // 比較に使用しないパラメータはnull or 固定値にする readModels.Where(x => x.Sid == 1).First().RowVersion = null; readModels.Where(x => x.Sid == 1).First().DtDeliveryFile.RowVersion = null; readModels.Where(x => x.Sid == 1).First().MtDeliveryGroupStatus.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00"); } // データのjson化 string readJson = Utility.ObjectExtensions.ToStringJson(readModels); string expectJson = null; if (File.Exists(expected_DataJsonPath)) { expectJson = File.ReadAllText(expected_DataJsonPath); } // データの比較 Assert.AreEqual(expectJson, readJson); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void ReadDtDeliveryFileTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { // 初期データ挿入 RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath); // データを取得する(配信結果付き) var readModel = _deliveryFileRepository.ReadDtDeliveryFile(2); if (readModel != null) { // 比較に使用しないパラメータはnullにする readModel.RowVersion = null; readModel.MtDeliveryFileType.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); }
public void UpdateDeviceInfoByTwinChangedTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { DtDeliveryGroup readDeliveryGroup = new DtDeliveryGroup() { Sid = 0 }; DtTwinChanged twinChangedData = new DtTwinChanged() { RemoteConnectionUid = RepositoryTestHelper.CreateSpecifiedNumberString(64), SoftVersion = RepositoryTestHelper.CreateSpecifiedNumberString(30), }; if (expected_ExceptionType == typeof(RmsParameterException).FullName) { if (expected_ExceptionMessage.Contains("RemoteConnectUid")) { twinChangedData.RemoteConnectionUid = RepositoryTestHelper.CreateSpecifiedNumberString(65); // 上限値+1 } else if (expected_ExceptionMessage.Contains("RmsSoftVersion")) { twinChangedData.SoftVersion = RepositoryTestHelper.CreateSpecifiedNumberString(31); // 上限値+1 } } // 初期データ挿入 RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath); string exceptionName = ""; string exceptionMessage = ""; try { if (expected_ExceptionType == typeof(ArgumentNullException).FullName) { twinChangedData = null; } // データを取得する(配信結果付き) var readModel = _deviceRepository.UpdateDeviceInfoByTwinChanged(2, twinChangedData); if (readModel != null) { readModel.UpdateDatetime = 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); // TODO DBデータ内容をチェックする } catch (RmsParameterException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (ArgumentNullException e) { exceptionName = e.GetType().FullName; exceptionMessage = typeof(DtDevice).FullName + " is null."; // HACK ←の部分をメッセージから抽出できれば... } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void ReadDtDeviceOnlineGatewayTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { DtDeliveryGroup readDeliveryGroup = new DtDeliveryGroup() { Sid = 0 }; // 初期データ挿入 if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath)) { // 配信グループを取得する readDeliveryGroup = _deliveryGroupRepository.ReadDtDeliveryGroup(1); Assert.IsNotNull(readDeliveryGroup); } string exceptionName = ""; string exceptionMessage = ""; try { if (expected_ExceptionType == typeof(ArgumentNullException).FullName) { readDeliveryGroup = null; } // データを取得する(配信結果付き) var readModel = _deviceRepository.ReadDtDeviceOnlineGateway(readDeliveryGroup); if (readModel.Count() != 0) { // 比較に使用しないパラメータはnull or 固定値にする readModel.ToList()[0].MtConnectStatus.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); } catch (ArgumentNullException e) { exceptionName = e.GetType().FullName; exceptionMessage = typeof(DtDevice).FullName + " is null."; // HACK ←の部分をメッセージから抽出できれば... } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void CreateDtDeliveryResultTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { // 初期データ挿入 RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath); // データを作成する var baseDateTime = DateTime.UtcNow; var newResultData = new DtDeliveryResult() { DeviceSid = 1, GwDeviceSid = 1, DeliveryGroupSid = 1, CreateDatetime = baseDateTime }; if (expected_ExceptionType == typeof(RmsException).FullName) { // 存在しないSidを指定する newResultData.DeviceSid = 999; } if (expected_ExceptionType == typeof(ArgumentNullException).FullName) { newResultData = null; } string exceptionName = ""; string exceptionMessage = ""; try { var createdResultData = _deliveryResultRepository.CreateDtDeliveryResult(newResultData); if (createdResultData != null) { // 作成日時はDB側で設定されることを確認する Assert.AreNotEqual(baseDateTime, createdResultData.CreateDatetime); // 比較に使用しない値はnull or 固定値とする createdResultData.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00"); } // データのjson化 string readJson = Utility.ObjectExtensions.ToStringJson(createdResultData); string expectJson = null; if (File.Exists(expected_DataJsonPath)) { expectJson = File.ReadAllText(expected_DataJsonPath); } // データの比較 Assert.AreEqual(expectJson, readJson); // TODO DBデータ内容をチェックする } catch (RmsException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (ArgumentNullException e) { exceptionName = e.GetType().FullName; exceptionMessage = typeof(DtDeliveryGroup).FullName + " is null."; // HACK ←の部分をメッセージから抽出できれば... } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void UpdateCancelFlagTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { bool canUpdate = false; DtDeliveryFile changedModel = new DtDeliveryFile() { Sid = 0 }; // 初期データ挿入 if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath)) { canUpdate = true; // RowVersion取得のため読み出す var readModel = _deliveryFileRepository.ReadDtDeliveryFile(2); Assert.IsNotNull(readModel); // 更新データ設定 changedModel.Sid = readModel.Sid; changedModel.DeliveryFileTypeSid = 2; changedModel.InstallTypeSid = 2; changedModel.FilePath = RepositoryTestHelper.CreateSpecifiedNumberString(301); // 変更されないので上限値+1 changedModel.Version = RepositoryTestHelper.CreateSpecifiedNumberString(31); // 変更されないので上限値+1 changedModel.InstallableVersion = RepositoryTestHelper.CreateSpecifiedNumberString(301); // 変更されないので上限値+1 changedModel.Description = RepositoryTestHelper.CreateSpecifiedNumberString(201); // 変更されないので上限値+1 changedModel.InformationId = RepositoryTestHelper.CreateSpecifiedNumberString(46); // 変更されないので上限値+1 changedModel.CreateDatetime = DateTime.Parse("2099/12/31 0:00:00"); changedModel.RowVersion = readModel.RowVersion; switch (no) { case "1_001": default: changedModel.IsCanceled = null; break; case "1_002": changedModel.IsCanceled = true; break; case "1_003": // 挿入SQLと同じ値 changedModel.IsCanceled = false; break; } } string exceptionName = ""; string exceptionMessage = ""; try { if (expected_ExceptionType == typeof(ArgumentNullException).FullName) { changedModel = null; } // データを更新する var updatedModel = _deliveryFileRepository.UpdateCancelFlag(changedModel); Assert.IsTrue((updatedModel != null) == canUpdate); if (changedModel.IsCanceled == false) { // 中止フラグが更新前と同一の場合は更新されていない(RowVersionに変化がない)ことを確認する Assert.IsTrue(changedModel.RowVersion.SequenceEqual(updatedModel.RowVersion)); } if (updatedModel != null) { // 比較に使用しないパラメータはnull or 固定値にする updatedModel.UpdateDatetime = DateTime.Parse("2020/4/1 0:00:00"); updatedModel.RowVersion = null; updatedModel.DtDeliveryModel.ToList()[0].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 (RmsParameterException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (ArgumentNullException e) { exceptionName = e.GetType().FullName; exceptionMessage = typeof(DtDeliveryFile).FullName + " is null."; // HACK ←の部分をメッセージから抽出できれば... } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void UpdateDtDeliveryFileIfNoGroupStartedTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { bool canUpdate = false; DtDeliveryFile changedModel = new DtDeliveryFile() { Sid = 0 }; // 初期データ挿入 if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath)) { canUpdate = true; // RowVersion取得のため読み出す var readModel = _deliveryFileRepository.ReadDtDeliveryFile(2); Assert.IsNotNull(readModel); // 更新データ設定 changedModel.Sid = readModel.Sid; changedModel.DeliveryFileTypeSid = 2; changedModel.InstallTypeSid = 2; changedModel.FilePath = RepositoryTestHelper.CreateSpecifiedNumberString(301); // 変更されないので上限値+1 changedModel.Version = RepositoryTestHelper.CreateSpecifiedNumberString(30); changedModel.InstallableVersion = RepositoryTestHelper.CreateSpecifiedNumberString(300); changedModel.Description = RepositoryTestHelper.CreateSpecifiedNumberString(200); changedModel.InformationId = RepositoryTestHelper.CreateSpecifiedNumberString(45); changedModel.IsCanceled = true; changedModel.CreateDatetime = DateTime.Parse("2099/12/31 0:00:00"); changedModel.RowVersion = readModel.RowVersion; // 子エンティティの設定 changedModel.DtDeliveryModel.Add(new DtDeliveryModel() { EquipmentModelSid = 2, CreateDatetime = DateTime.Parse("2020/4/1 0:00:00") }); if (expected_ExceptionType == typeof(RmsParameterException).FullName) { if (expected_ExceptionMessage.Contains("InstallableVersion")) { changedModel.InstallableVersion = RepositoryTestHelper.CreateSpecifiedNumberString(301); // 上限値+1 } else if (expected_ExceptionMessage.Contains("Version")) { changedModel.Version = RepositoryTestHelper.CreateSpecifiedNumberString(31); // 上限値+1 } else if (expected_ExceptionMessage.Contains("Description")) { changedModel.Description = RepositoryTestHelper.CreateSpecifiedNumberString(201); // 上限値+1 } else if (expected_ExceptionMessage.Contains("InformationId")) { changedModel.InformationId = RepositoryTestHelper.CreateSpecifiedNumberString(46); // 上限値+1 } } } string exceptionName = ""; string exceptionMessage = ""; try { if (expected_ExceptionType == typeof(ArgumentNullException).FullName) { changedModel = null; } // データを更新する var updatedModel = _deliveryFileRepository.UpdateDtDeliveryFileIfNoGroupStarted(changedModel); Assert.IsTrue((updatedModel != null) == canUpdate); if (updatedModel != null) { // 比較に使用しないパラメータはnull or 固定値にする updatedModel.UpdateDatetime = DateTime.Parse("2020/4/1 0:00:00"); updatedModel.RowVersion = null; updatedModel.DtDeliveryModel.ToList()[0].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); // 挿入SQLで登録した配信ファイル型式は削除されていることを確認する var readDeliveryModel = _deliveryModelRepository.ReadDtDeliveryModel(1); Assert.IsNull(readDeliveryModel); // TODO DBデータ内容をチェックする } catch (RmsCannotChangeDeliveredFileException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (RmsParameterException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (ArgumentNullException e) { exceptionName = e.GetType().FullName; exceptionMessage = typeof(DtDeliveryFile).FullName + " is null."; // HACK ←の部分をメッセージから抽出できれば... } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void SaveFromParentTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { // 初期データ挿入 RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath); // データを作成する var newParentData = new DtParentChildConnectFromParent() { ParentDeviceUid = "ParentDeviceUid", ChildDeviceUid = "ChildDeviceUid", ParentResult = false, ParentConfirmDatetime = DateTime.Parse("2020/4/2 0:00:00") }; if (expected_ExceptionType == typeof(RmsException).FullName) { // 各パラメータでnull非許容の場合の確認 if (remarks.Contains("ParentResult")) { newParentData.ParentResult = null; } else if (remarks.Contains("ParentConfirmDatetime")) { newParentData.ParentConfirmDatetime = null; } else if (remarks.Contains("All")) { newParentData = null; } else { // UIDを存在しないものにする newParentData.ParentDeviceUid = null; newParentData.ChildDeviceUid = null; } } string exceptionName = ""; string exceptionMessage = ""; try { var savedParentData = _parentChildConnectRepository.Save(newParentData); if (savedParentData != null) { // 比較に使用しない値はnull or 固定値とする savedParentData.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00"); savedParentData.UpdateDatetime = DateTime.Parse("2020/4/1 0:00:00"); } // データのjson化 string readJson = Utility.ObjectExtensions.ToStringJson(savedParentData); string expectJson = null; if (File.Exists(expected_DataJsonPath)) { expectJson = File.ReadAllText(expected_DataJsonPath); } // データの比較 Assert.AreEqual(expectJson, readJson); // TODO DBデータ内容をチェックする } catch (RmsAlreadyExistException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (RmsException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void UpdateDtDeliveryGroupIfDeliveryNotStartTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { DtDeliveryGroup changedModel = new DtDeliveryGroup() { Sid = 0 }; bool canDelete = false; // 初期データ挿入 if (RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath)) { canDelete = true; // RowVersion取得のため読み出す var readModel = _deliveryGroupRepository.ReadDtDeliveryGroup(1); Assert.IsNotNull(readModel); // データを更新する(SIDは変更すると動作しないので変更しない) changedModel.Sid = readModel.Sid; changedModel.DeliveryGroupStatusSid = 999; changedModel.MtDeliveryGroupStatus = null; changedModel.DeliveryFileSid = 999; changedModel.Name = RepositoryTestHelper.CreateSpecifiedNumberString(100); changedModel.StartDatetime = DateTime.Parse("2020/4/2 0:00:00"); changedModel.DownloadDelayTime = 10; changedModel.CreateDatetime = DateTime.UtcNow; if (expected_ExceptionType.Equals(typeof(RmsParameterException).FullName)) { // 異常値を設定する changedModel.Name = RepositoryTestHelper.CreateSpecifiedNumberString(101); } } string exceptionName = ""; string exceptionMessage = ""; try { // データを更新する var updatedModel = _deliveryGroupRepository.UpdateDtDeliveryGroupIfDeliveryNotStart(changedModel); Assert.IsTrue((updatedModel != null) == canDelete); 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; } catch (RmsParameterException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }
public void CreateDtDirectoryUsageIfAlreadyMessageThrowExTest( string no, string in_InsertNewDataSqlPath, string in_DeleteNewDataSqlPath, string expected_DataJsonPath, string expected_ExceptionType, string expected_ExceptionMessage, string remarks) { // 初期データ挿入 RepositoryTestHelper.ExecInsertSql(in_InsertNewDataSqlPath); // データを作成する var baseDateTime = DateTime.UtcNow; var newDirectoryUsageData = new DtDirectoryUsage() { DeviceSid = 1, SourceEquipmentUid = RepositoryTestHelper.CreateSpecifiedNumberString(30), // 上限値いっぱい MessageId = RepositoryTestHelper.CreateSpecifiedNumberString(64), // 上限値いっぱい、既存でないメッセージID CreateDatetime = baseDateTime }; if (expected_ExceptionType == typeof(RmsException).FullName) { // 存在しないSidを指定する newDirectoryUsageData.DeviceSid = 999; } else if (expected_ExceptionType == typeof(ArgumentNullException).FullName) { newDirectoryUsageData = null; } else if (expected_ExceptionType == typeof(RmsAlreadyExistException).FullName) { newDirectoryUsageData.MessageId = "hoge"; // 既存のメッセージID } else if (expected_ExceptionType == typeof(RmsParameterException).FullName) { if (expected_ExceptionMessage.Contains("SourceEquipmentUid")) { newDirectoryUsageData.SourceEquipmentUid = RepositoryTestHelper.CreateSpecifiedNumberString(65); // 上限値+1 } else if (expected_ExceptionMessage.Contains("MessageId")) { newDirectoryUsageData.MessageId = RepositoryTestHelper.CreateSpecifiedNumberString(65); // 上限値+1、既存でないメッセージ } } string exceptionName = ""; string exceptionMessage = ""; try { var createdDirectoryUsageData = _directoryUsageRepository.CreateDtDirectoryUsageIfAlreadyMessageThrowEx(newDirectoryUsageData); if (createdDirectoryUsageData != null) { // 作成日時はDB側で設定されることを確認する Assert.AreNotEqual(baseDateTime, createdDirectoryUsageData.CreateDatetime); // 比較に使用しない値はnull or 固定値とする createdDirectoryUsageData.CreateDatetime = DateTime.Parse("2020/4/1 0:00:00"); } // データのjson化 string readJson = Utility.ObjectExtensions.ToStringJson(createdDirectoryUsageData); string expectJson = null; if (File.Exists(expected_DataJsonPath)) { expectJson = File.ReadAllText(expected_DataJsonPath); } // データの比較 Assert.AreEqual(expectJson, readJson); // TODO DBデータ内容をチェックする } catch (RmsAlreadyExistException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (RmsParameterException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (RmsException e) { exceptionName = e.GetType().FullName; exceptionMessage = e.Message; } catch (ArgumentNullException e) { exceptionName = e.GetType().FullName; exceptionMessage = typeof(DtDirectoryUsage).FullName + " is null."; // HACK ←の部分をメッセージから抽出できれば... } // 例外発生チェック Assert.AreEqual(expected_ExceptionType, exceptionName); Assert.AreEqual(expected_ExceptionMessage, exceptionMessage); // 後処理 RepositoryTestHelper.ExecDeleteSql(in_DeleteNewDataSqlPath); }