コード例 #1
0
        public CreateCifAndAccountResponseModel CreateCifAndAccount(CreateCifAndAccountRequestModel requestModel, DateTime processDateTime)
        {
            Logging.WriteLog(requestModel);
            CreateCifAndAccountResponseModel responseModel = new CreateCifAndAccountResponseModel();

            requestModel.ThaiName     = SetFirstnameWithMiddlename(requestModel.ThaiName, requestModel.ThaiMiddleName);
            requestModel.EngName      = SetFirstnameWithMiddlename(requestModel.EngName, requestModel.EngMiddleName);
            responseModel.ReferenceNo = requestModel.ReferenceNo;
            try
            {
                MBaseMessageModel mBaseMessageModel = CreateCifAccountMessage(requestModel, processDateTime);

                var mBaseMessage = MBaseMessageMatchObject(mBaseMessageModel);
                // MBase CIFCreate
                var mBaseResponse = MBaseSingleton.Instance.CIFCreation(mBaseMessage);

                // Output Matching Object
                PropertyMatcher <CIFAccountResponse, CreateCifAndAccountResponseModel> .GenerateMatchedObject(mBaseResponse, responseModel);
            }
            catch (Exception ex)
            {
                responseModel.ErrorCode        = ResponseCode.EXC0001;
                responseModel.ErrorDescription = ex.Message;
            }
            finally
            {
                Logging.WriteLog(responseModel);
            }
            return(responseModel);
        }
コード例 #2
0
        public VerifyCitizenResponseModel VerifyCitizenID(VerifyCitizenRequestModel requestModel, DateTime processDateTime)
        {
            Logging.WriteLog(requestModel);
            VerifyCitizenResponseModel responseModel = new VerifyCitizenResponseModel();

            try
            {
                MBaseMessageModel mBaseMessageModel = VerifyCitizenMessage(requestModel, processDateTime);

                var mBaseMessage = MBaseMessageMatchObject(mBaseMessageModel);
                // MBase Verify Citizen ID
                var mBaseResponse = MBaseSingleton.Instance.VerifyCitizenID(mBaseMessage);

                // Output Matching Object

                PropertyMatcher <VerifyCitizenResponse, VerifyCitizenResponseModel> .GenerateMatchedObject(mBaseResponse, responseModel);

                Logging.WriteLog(responseModel);
            }
            catch (Exception ex)
            {
                Logging.WriteLog(ex.Message + ":" + ex.StackTrace);
            }
            return(responseModel);
        }
コード例 #3
0
        public VerifyCitizenResponseModel VerifyCitizenID(VerifyCitizenRequestModel requestModel, DateTime processDateTime)
        {
            Logging.WriteLog(requestModel);
            VerifyCitizenResponseModel responseModel = new VerifyCitizenResponseModel();

            responseModel.ReferenceNo = requestModel.ReferenceNo;
            try
            {
                MBaseMessageModel mBaseMessageModel = VerifyCitizenMessage(requestModel, processDateTime);

                var mBaseMessage = MBaseMessageMatchObject(mBaseMessageModel);
                // MBase Verify Citizen ID
                var mBaseResponse = MBaseSingleton.Instance.VerifyCitizenID(mBaseMessage);

                // Output Matching Object
                PropertyMatcher <VerifyCitizenResponse, VerifyCitizenResponseModel> .GenerateMatchedObject(mBaseResponse, responseModel);
            }
            catch (Exception ex)
            {
                responseModel.ErrorCode        = ResponseCode.EXC0001;
                responseModel.ErrorDescription = ex.Message;
            }
            finally
            {
                Logging.WriteLog(responseModel);
            }
            return(responseModel);
        }
コード例 #4
0
        public void DoesNotMatchWriteOnlyProperty()
        {
            ObjectWithProperties o = new ObjectWithProperties();

            Matcher m = new PropertyMatcher("WriteOnlyProperty", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o");
        }
コード例 #5
0
        public void DoesNotMatchObjectIfItDoesNotHaveNamedProperty()
        {
            ObjectWithProperties o = new ObjectWithProperties();

            Matcher m = new PropertyMatcher("OtherProperty", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o");
        }
コード例 #6
0
        public void MatchesObjectWithNamedPropertyAndMatchingPropertyValue()
        {
            ObjectWithProperties o = new ObjectWithProperties();
            object aValue          = new NamedObject("aValue");

            o.A = aValue;

            Matcher m = new PropertyMatcher("A", Is.EqualTo(aValue));

            Assert.IsTrue(m.Matches(o), "should match o");
        }
コード例 #7
0
        public void DoesNotMatchObjectIfPropertyMatcherDoesNotMatch()
        {
            ObjectWithProperties o = new ObjectWithProperties();
            object aValue          = new NamedObject("aValue");
            object otherValue      = new NamedObject("otherValue");

            o.A = aValue;

            Matcher m = new PropertyMatcher("A", new EqualMatcher(otherValue));

            Assert.IsFalse(m.Matches(o), "should not match o");
        }
コード例 #8
0
        public void IsMatch_Should_Return_For_For_Different_Name()
        {
            var source = new Property()
            {
                Name = "*Super*-High! APARTMENTS (Sydney)", Address = "32 Sir John-Young Crescent, Sydney, NSW.", AgencyCode = "OTBRE", Latitude = 100, Longitude = 105
            };
            var compareWIth = new Property()
            {
                Name = "*Super High Apartments, Sydneys", Address = "32 Sir John Young Crescent, Sydney NSW", AgencyCode = "OTBRE", Latitude = 1003, Longitude = 1045
            };
            var matcher = new PropertyMatcher();
            var result  = matcher.IsMatch(source, compareWIth);

            Assert.IsFalse(result);
        }
コード例 #9
0
        public async Task CreateConfigIfOneDoesNotExist()
        {
            // Arrange
            var guildId        = (ulong)1000L;
            var expectedResult = new GuildConfig {
                GuildID = guildId
            };

            // Act
            var result = await guildService.GetOrCreateConfigAsync(guildId);

            // Assert
            PropertyMatcher.Match(expectedResult, result);
            _mockGuildConfig.Verify(d => d.Add(Match.Create <GuildConfig>(g => g.GuildID == guildId)), Times.Once);
            _monkeyDbContext.Verify(c => c.SaveChangesAsync(default), Times.Once);
コード例 #10
0
        public void IsMatch_Should_Return_False_For_Different_Reverse_Name_2()
        {
            var source = new Property()
            {
                Name = "Flat Summit This", Address = "32 Sir John-Young Crescent, Sydney, NSW.", AgencyCode = "CRE", Latitude = 106.006M, Longitude = 104.006M
            };
            var compareWIth = new Property()
            {
                Name = "This Summits Flat", Address = "32 Sir John-Young Crescent, Sydney, NSW.s", AgencyCode = "CRE", Latitude = 106.0042072072072M, Longitude = 104.0042072072172M
            };
            var matcher = new PropertyMatcher();
            var result  = matcher.IsMatch(source, compareWIth);

            Assert.IsFalse(result);
        }
コード例 #11
0
        public void IsMatch_Should_Return_False_For_Different_Agency_Within_200M()
        {
            var source = new Property()
            {
                Name = "*Super*-High! APARTMENTS (Sydney)", Address = "32 Sir John-Young Crescent, Sydney, NSW.", AgencyCode = "LRE", Latitude = 106.006M, Longitude = 104.006M
            };
            var compareWIth = new Property()
            {
                Name = "*Super High Apartments, Sydney", Address = "32 Sir John Young Crescent, Sydney NSWs", AgencyCode = "LREA", Latitude = 106.006M, Longitude = 104.006M
            };
            var matcher = new PropertyMatcher();
            var result  = matcher.IsMatch(source, compareWIth);

            Assert.IsFalse(result);
        }
コード例 #12
0
        public void IsMatch_Should_Return_True_For_Reverse_Name()
        {
            var source = new Property()
            {
                Name = "Apartments Summit The", Address = "32 Sir John-Young Crescent, Sydney, NSW.", AgencyCode = "CRE", Latitude = 106.006M, Longitude = 104.006M
            };
            var compareWIth = new Property()
            {
                Name = "The Summit Apartments", Address = "32 Sir John-Young Crescent, Sydney, NSW.s", AgencyCode = "CRE", Latitude = 106.0042072072072M, Longitude = 104.0042072072172M
            };
            var matcher = new PropertyMatcher();
            var result  = matcher.IsMatch(source, compareWIth);

            Assert.IsTrue(result);
        }
コード例 #13
0
        public void IsMatch_Should_Return_False_For_Same_Agency_Over_200M()
        {
            var source = new Property()
            {
                Name = "Super High Apartments, Sydney", Address = "32 Sir John-Young Crescent, Sydney, NSW.", AgencyCode = "LRE", Latitude = 106.006M, Longitude = 106.006M
            };
            var compareWIth = new Property()
            {
                Name = "Super High Apartments, Sydneys", Address = "32 Sir John-Young Crescent, Sydney, NSW.s", AgencyCode = "LRE", Latitude = 106.0078108108108M, Longitude = 106.0078108108108M
            };
            var matcher = new PropertyMatcher();
            var result  = matcher.IsMatch(source, compareWIth);

            Assert.IsFalse(result);
        }
コード例 #14
0
        private MBaseMessage MBaseMessageMatchObject(MBaseMessageModel messageModel)
        {
            // Header Transaction
            var headerTransaction = new MBaseHeaderTransaction();

            PropertyMatcher <HeaderTransactionModel, MBaseHeaderTransaction> .GenerateMatchedObject(messageModel.HeaderTransaction, headerTransaction);

            // Header Message
            var headerMessages = new List <MBaseMessageType>();

            foreach (var itmType in messageModel.HeaderMessages)
            {
                var mbaseMessageType = new MBaseMessageType();
                PropertyMatcher <MessageTypeModel, MBaseMessageType> .GenerateMatchedObject(itmType, mbaseMessageType);

                headerMessages.Add(mbaseMessageType);
            }

            // Input Message
            var inputMessages = new List <MBaseMessageType>();

            foreach (var itmType in messageModel.InputMessages)
            {
                var mbaseMessageType = new MBaseMessageType();
                PropertyMatcher <MessageTypeModel, MBaseMessageType> .GenerateMatchedObject(itmType, mbaseMessageType);

                inputMessages.Add(mbaseMessageType);
            }

            // Response Message
            var responseMessages = new List <MBaseMessageType>();

            foreach (var itmType in messageModel.ResponseMessages)
            {
                var mbaseMessageType = new MBaseMessageType();
                PropertyMatcher <MessageTypeModel, MBaseMessageType> .GenerateMatchedObject(itmType, mbaseMessageType);

                responseMessages.Add(mbaseMessageType);
            }
            return(new MBaseMessage
            {
                HeaderTransaction = headerTransaction,
                HeaderMessages = headerMessages,
                InputMessages = inputMessages,
                ResponseMessages = responseMessages
            });
        }
コード例 #15
0
        public async Task ShouldGetLatestComic()
        {
            // Arrange
            var number = 69;
            var latestResponseHandler = PrepareMockResponseHandlerForLatest(number);
            var httpClient            = PrepareHttpClient(latestResponseHandler);

            _mockHttpClientFactory.Setup(f => f.CreateClient(It.IsAny <string>())).Returns(httpClient);

            var xkcdResponse = PrepareXkcdResponse(number);

            // Act
            var latestComic = await xkcdService.GetLatestComicAsync();

            // Assert
            PropertyMatcher.Match(xkcdResponse, latestComic);
        }
コード例 #16
0
        public CIFAddressResponseModel CIFAddressCreate(CIFAddresRequestModel requestModel, DateTime processDateTime)
        {
            Logging.WriteLog(requestModel);
            MBaseMessageModel mBaseMessageModel = CIFAddressCreateMessage(requestModel, processDateTime);

            var mBaseMessage = MBaseMessageMatchObject(mBaseMessageModel);
            // MBase CIFCreate
            var mBaseResponse = MBaseSingleton.Instance.CIFAddressCreation(mBaseMessage);

            // Output Matching Object
            CIFAddressResponseModel responseModel = new CIFAddressResponseModel();

            PropertyMatcher <CIFAddressResponse, CIFAddressResponseModel> .GenerateMatchedObject(mBaseResponse, responseModel);

            Logging.WriteLog(responseModel);
            return(responseModel);
        }
コード例 #17
0
        public KycCIFLevelResponseModel KycCIFLevelCreate(KycCIFLevelRequestModel requestModel, DateTime processDateTime)
        {
            Logging.WriteLog(requestModel);
            MBaseMessageModel mBaseMessageModel = KycCIFLevelCreateMessage(requestModel, processDateTime);

            var mBaseMessage = MBaseMessageMatchObject(mBaseMessageModel);
            // MBase CIFCreate
            var mBaseResponse = MBaseSingleton.Instance.CreateKycCIFLevelMessage(mBaseMessage);

            // Output Matching Object
            KycCIFLevelResponseModel responseModel = new KycCIFLevelResponseModel();

            PropertyMatcher <KycCIFLevelResponse, KycCIFLevelResponseModel> .GenerateMatchedObject(mBaseResponse, responseModel);

            Logging.WriteLog(responseModel);
            return(responseModel);
        }
コード例 #18
0
        public async Task GetComicByNumber()
        {
            // Arrange
            var maxNumber             = 690;
            var comicNumber           = 420;
            var latestResponseHandler = PrepareMockResponseHandlerForLatest(maxNumber);

            PrepareMockResponseHandler(latestResponseHandler, comicNumber);
            var httpClient = PrepareHttpClient(latestResponseHandler);

            _mockHttpClientFactory.Setup(f => f.CreateClient(It.IsAny <string>())).Returns(httpClient);

            var expectedComic = PrepareXkcdResponse(comicNumber);

            // Act
            var comic = await xkcdService.GetComicAsync(comicNumber);

            // Assert
            PropertyMatcher.Match(expectedComic, comic);
        }
コード例 #19
0
 public void Setup()
 {
     _propertyMatcher = new PropertyMatcher();
 }
コード例 #20
0
        public CreateCifAddressResponseModel CreateCifAddress(CreateCifAddresRequestModel requestModel, DateTime processDateTime)
        {
            Logging.WriteLog(requestModel);
            CreateCifAddressResponseModel responseModel = new CreateCifAddressResponseModel();

            responseModel.ReferenceNo = requestModel.ReferenceNo;
            try
            {
                string   houseNo     = requestModel.HouseNo.Trim();
                string   villageNo   = requestModel.VillageNo.Trim();
                string   building    = requestModel.Building.Trim();
                string   floor       = requestModel.Floor.Trim();
                string   room        = requestModel.Room.Trim();
                string   alley       = requestModel.Alley.Trim();
                string   lane        = requestModel.Lane.Trim();
                string   road        = requestModel.Road.Trim();
                string   subDistrict = requestModel.SubDistrict.Trim();
                string   district    = requestModel.District.Trim();
                string   province    = requestModel.Province.Trim();
                string   zipCode     = requestModel.ZipCode.Trim();
                string[] addressLine =
                {
                    houseNo, villageNo, building, floor, room, alley, lane, road, subDistrict
                };
                var dictAddressLine = GetAddressLine(addressLine);
                foreach (var address in dictAddressLine)
                {
                    switch (address.Key)
                    {
                    case nameof(requestModel.AddressLine1):
                        requestModel.AddressLine1 = address.Value;
                        break;

                    case nameof(requestModel.AddressLine2):
                        requestModel.AddressLine2 = address.Value;
                        break;

                    case nameof(requestModel.AddressLine3):
                        requestModel.AddressLine3 = address.Value;
                        break;

                    case nameof(requestModel.AddressLine4):
                        requestModel.AddressLine4 = address.Value;
                        break;

                    case nameof(requestModel.AddressLine5):
                        requestModel.AddressLine5 = address.Value;
                        break;
                    }
                }

                requestModel.CityStateZip = $"{requestModel.District} {requestModel.Province} {requestModel.ZipCode}";

                MBaseMessageModel mBaseMessageModel = CreateCifAddressMessage(requestModel, processDateTime);

                var mBaseMessage = MBaseMessageMatchObject(mBaseMessageModel);
                // MBase CIFCreate
                var mBaseResponse = MBaseSingleton.Instance.CIFAddressCreation(mBaseMessage);

                // Output Matching Object
                PropertyMatcher <CIFAddressResponse, CreateCifAddressResponseModel> .GenerateMatchedObject(mBaseResponse, responseModel);
            }
            catch (Exception ex)
            {
                responseModel.ErrorCode        = ResponseCode.EXC0001;
                responseModel.ErrorDescription = ex.Message;
            }
            finally
            {
                Logging.WriteLog(responseModel);
            }
            return(responseModel);
        }