コード例 #1
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);
        }
コード例 #2
0
        public void ReadDtDeliveryGroupTest(
            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 = _deliveryGroupRepository.ReadDtDeliveryGroup(1);

            if (readModel != null)
            {
                // 比較に使用しないパラメータはnullにする
                readModel.RowVersion = null;
            }

            // データの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);
        }
コード例 #3
0
        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);
        }