Beispiel #1
0
        public void EventSourceClient_SegmentUpdateEvent_ShouldReceiveEvent()
        {
            using (var httpClientMock = new HttpClientMock())
            {
                var notification = "id: 234234432\nevent: message\ndata: {\"id\":\"jSOE7oGJWo:0:0\",\"clientId\":\"pri:ODc1NjQyNzY1\",\"timestamp\":1588254699236,\"encoding\":\"json\",\"channel\":\"xxxx_xxxx_segments\",\"data\":\"{\\\"type\\\":\\\"SEGMENT_UPDATE\\\",\\\"changeNumber\\\":1585868933303,\\\"segmentName\\\":\\\"test-segment\\\"}\"}";
                httpClientMock.SSE_Channels_Response(notification);

                var url            = httpClientMock.GetUrl();
                var eventsReceived = new BlockingCollection <EventReceivedEventArgs>(new ConcurrentQueue <EventReceivedEventArgs>());
                var actionEvent    = new BlockingCollection <SSEActionsEventArgs>(new ConcurrentQueue <SSEActionsEventArgs>());

                var notificationParser       = new NotificationParser();
                var wrapperAdapter           = new WrapperAdapter();
                var sseHttpClient            = new SplitioHttpClient("api-key", 5000);
                var telemetryRuntimeProducer = new InMemoryTelemetryStorage();

                var eventSourceClient = new EventSourceClient(notificationParser, wrapperAdapter, sseHttpClient, telemetryRuntimeProducer, new TasksManager(wrapperAdapter));
                eventSourceClient.EventReceived += delegate(object sender, EventReceivedEventArgs e)
                {
                    eventsReceived.TryAdd(e);
                };
                eventSourceClient.ActionEvent += delegate(object sender, SSEActionsEventArgs e)
                {
                    actionEvent.TryAdd(e);
                };
                eventSourceClient.ConnectAsync(url);

                eventsReceived.TryTake(out EventReceivedEventArgs ev, 10000);
                Assert.AreEqual(NotificationType.SEGMENT_UPDATE, ev.Event.Type);
                Assert.AreEqual(1585868933303, ((SegmentChangeNotification)ev.Event).ChangeNumber);
                Assert.AreEqual("test-segment", ((SegmentChangeNotification)ev.Event).SegmentName);
                actionEvent.TryTake(out SSEActionsEventArgs action, 10000);
                Assert.AreEqual(SSEClientActions.CONNECTED, action.Action);
            }
        }
Beispiel #2
0
        public void EventSourceClient_NotificationError_ShouldReceiveError()
        {
            using (var httpClientMock = new HttpClientMock())
            {
                var notification = "event: error\ndata: {\"message\":\"Token expired\",\"code\":40142,\"statusCode\":401,\"href\":\"https://help.ably.io/error/40142\"}\n\n";
                httpClientMock.SSE_Channels_Response(notification);

                var url            = httpClientMock.GetUrl();
                var eventsReceived = new BlockingCollection <EventReceivedEventArgs>(new ConcurrentQueue <EventReceivedEventArgs>());
                var actionEvent    = new BlockingCollection <SSEActionsEventArgs>(new ConcurrentQueue <SSEActionsEventArgs>());

                var notificationParser       = new NotificationParser();
                var wrapperAdapter           = new WrapperAdapter();
                var sseHttpClient            = new SplitioHttpClient("api-key", 5000);
                var telemetryRuntimeProducer = new InMemoryTelemetryStorage();

                var eventSourceClient = new EventSourceClient(notificationParser, wrapperAdapter, sseHttpClient, telemetryRuntimeProducer, new TasksManager(wrapperAdapter));
                eventSourceClient.EventReceived += delegate(object sender, EventReceivedEventArgs e)
                {
                    eventsReceived.TryAdd(e);
                };
                eventSourceClient.ActionEvent += delegate(object sender, SSEActionsEventArgs e)
                {
                    actionEvent.TryAdd(e);
                };
                eventSourceClient.ConnectAsync(url);

                actionEvent.TryTake(out SSEActionsEventArgs action, 10000);
                Assert.AreEqual(SSEClientActions.DISCONNECT, action.Action);
            }
        }
Beispiel #3
0
        public void EventSourceClient_KeepAliveResponse()
        {
            using (var httpClientMock = new HttpClientMock())
            {
                httpClientMock.SSE_Channels_Response(":keepalive\n\n");

                var url            = httpClientMock.GetUrl();
                var eventsReceived = new BlockingCollection <EventReceivedEventArgs>(new ConcurrentQueue <EventReceivedEventArgs>());
                var actionEvent    = new BlockingCollection <SSEActionsEventArgs>(new ConcurrentQueue <SSEActionsEventArgs>());

                var notificationParser       = new NotificationParser();
                var wrapperAdapter           = new WrapperAdapter();
                var sseHttpClient            = new SplitioHttpClient("api-key", 5000);
                var telemetryRuntimeProducer = new InMemoryTelemetryStorage();

                var eventSourceClient = new EventSourceClient(notificationParser, wrapperAdapter, sseHttpClient, telemetryRuntimeProducer, new TasksManager(wrapperAdapter));
                eventSourceClient.EventReceived += delegate(object sender, EventReceivedEventArgs e)
                {
                    eventsReceived.TryAdd(e);
                };
                eventSourceClient.ActionEvent += delegate(object sender, SSEActionsEventArgs e)
                {
                    actionEvent.TryAdd(e);
                };
                eventSourceClient.ConnectAsync(url);

                actionEvent.TryTake(out SSEActionsEventArgs action, 10000);
                Assert.AreEqual(SSEClientActions.CONNECTED, action.Action);
                Thread.Sleep(1000);
                Assert.AreEqual(0, eventsReceived.Count);
            }
        }
Beispiel #4
0
        public void EventSourceClient_ControlEvent_StreamingDisabled_ShouldReceiveEvent()
        {
            using (var httpClientMock = new HttpClientMock())
            {
                var notification = "id: 234234432\nevent: message\ndata: {\"id\":\"jSOE7oGJWo:0:0\",\"clientId\":\"pri:ODc1NjQyNzY1\",\"timestamp\":1588254699236,\"encoding\":\"json\",\"channel\":\"[?occupancy=metrics.publishers]control_pri\",\"data\":\"{\\\"type\\\":\\\"CONTROL\\\",\\\"controlType\\\":\\\"STREAMING_DISABLED\\\"}\"}";
                httpClientMock.SSE_Channels_Response(notification);

                var url            = httpClientMock.GetUrl();
                var eventsReceived = new BlockingCollection <EventReceivedEventArgs>(new ConcurrentQueue <EventReceivedEventArgs>());
                var actionEvent    = new BlockingCollection <SSEActionsEventArgs>(new ConcurrentQueue <SSEActionsEventArgs>());

                var notificationParser       = new NotificationParser();
                var wrapperAdapter           = new WrapperAdapter();
                var sseHttpClient            = new SplitioHttpClient("api-key", 5000);
                var telemetryRuntimeProducer = new InMemoryTelemetryStorage();

                var eventSourceClient = new EventSourceClient(notificationParser, wrapperAdapter, sseHttpClient, telemetryRuntimeProducer, new TasksManager(wrapperAdapter));
                eventSourceClient.EventReceived += delegate(object sender, EventReceivedEventArgs e)
                {
                    eventsReceived.TryAdd(e);
                };
                eventSourceClient.ActionEvent += delegate(object sender, SSEActionsEventArgs e)
                {
                    actionEvent.TryAdd(e);
                };
                eventSourceClient.ConnectAsync(url);

                eventsReceived.TryTake(out EventReceivedEventArgs ev, 10000);
                Assert.AreEqual(NotificationType.CONTROL, ev.Event.Type);
                Assert.AreEqual(ControlType.STREAMING_DISABLED, ((ControlNotification)ev.Event).ControlType);
                actionEvent.TryTake(out SSEActionsEventArgs action, 10000);
                Assert.AreEqual(SSEClientActions.CONNECTED, action.Action);
            }
        }
        public void ParseNotification_OnlineDebit_Test()
        {
            NotificationParser notificationParser = new NotificationParser();

            var statusNotification = notificationParser.ParseNotification(onlineDebitNotification);

            Assert.AreEqual(7000, statusNotification.AmountInCents);
            Assert.AreEqual(7000, statusNotification.AmountPaidInCents);
            Assert.IsNotNull(statusNotification.OnlineDebitTransaction);
            Assert.AreEqual(Guid.Parse("B1B1092C-8681-40C2-A734-500F22683D9B"), statusNotification.MerchantKey);
            Assert.AreEqual(Guid.Parse("1025FCB5-41D8-43B5-82FE-398F61E83879"), statusNotification.OrderKey);
            Assert.AreEqual("9623472", statusNotification.OrderReference);
            Assert.AreEqual(OrderStatusEnum.Paid, statusNotification.OrderStatus);

            // OnlineDebitTransaction
            Assert.AreEqual(7000, statusNotification.OnlineDebitTransaction.AmountInCents);
            Assert.AreEqual(7000, statusNotification.OnlineDebitTransaction.AmountPaidInCents);
            Assert.AreEqual("BancoDoBrasil", statusNotification.OnlineDebitTransaction.BankName);
            Assert.AreEqual("22092015", statusNotification.OnlineDebitTransaction.BankPaymentDate);
            Assert.AreEqual(ParseDateTime("2015-09-22T13:15:46.333"), statusNotification.OnlineDebitTransaction.StatusChangedDate);
            Assert.AreEqual(Guid.Parse("751AE9F0-AF0B-4DE5-A483-2EFF2DE0FDF6"), statusNotification.OnlineDebitTransaction.TransactionKey);
            Assert.AreEqual("00000000000012345", statusNotification.OnlineDebitTransaction.TransactionKeyToBank);
            Assert.AreEqual("656885531", statusNotification.OnlineDebitTransaction.TransactionReference);
            Assert.AreEqual(OnlineDebitTransactionStatusEnum.OpenedPendingPayment, statusNotification.OnlineDebitTransaction.PreviousOnlineDebitTransactionStatus);
            Assert.AreEqual(OnlineDebitTransactionStatusEnum.Paid, statusNotification.OnlineDebitTransaction.OnlineDebitTransactionStatus);
        }
        public void ParseNotification_Boleto_Test()
        {
            NotificationParser notificationParser = new NotificationParser();

            var statusNotification = notificationParser.ParseNotification(boletoNotification);

            Assert.AreEqual(1000, statusNotification.AmountInCents);
            Assert.AreEqual(1000, statusNotification.AmountPaidInCents);
            Assert.IsNotNull(statusNotification.BoletoTransaction);
            Assert.IsNull(statusNotification.OnlineDebitTransaction);
            Assert.AreEqual(Guid.Parse("B1B1092C-8681-40C2-A734-500F22683D9B"), statusNotification.MerchantKey);
            Assert.AreEqual(Guid.Parse("60365605-1D43-487D-AE4C-8B7DC5BAA213"), statusNotification.OrderKey);
            Assert.AreEqual("9657412", statusNotification.OrderReference);
            Assert.AreEqual(OrderStatusEnum.Paid, statusNotification.OrderStatus);

            // BoletoTransaction
            Assert.AreEqual(1000, statusNotification.BoletoTransaction.AmountInCents);
            Assert.AreEqual(1000, statusNotification.BoletoTransaction.AmountPaidInCents);
            Assert.AreEqual(ParseDateTime("2015-09-21T15:42:04.573"), statusNotification.BoletoTransaction.BoletoExpirationDate);
            Assert.AreEqual("0123456789", statusNotification.BoletoTransaction.NossoNumero);
            Assert.AreEqual(ParseDateTime("2015-09-22T07:06:00.537"), statusNotification.BoletoTransaction.StatusChangedDate);
            Assert.AreEqual(Guid.Parse("F7C4B737-E8B5-4BAA-BB47-6ED2A1A1EE09"), statusNotification.BoletoTransaction.TransactionKey);
            Assert.AreEqual("6741137", statusNotification.BoletoTransaction.TransactionReference);
            Assert.AreEqual(BoletoTransactionStatusEnum.Generated, statusNotification.BoletoTransaction.PreviousBoletoTransactionStatus);
            Assert.AreEqual(BoletoTransactionStatusEnum.Paid, statusNotification.BoletoTransaction.BoletoTransactionStatus);
        }
        public void ParseNotification_AllFields_Test()
        {
            NotificationParser notificationParser = new NotificationParser();

            var statusNotification = notificationParser.ParseNotification(fullNotification);

            Assert.AreEqual(8500, statusNotification.AmountInCents);
            Assert.AreEqual(8500, statusNotification.AmountPaidInCents);
            Assert.IsNotNull(statusNotification.OnlineDebitTransaction);
            Assert.IsNotNull(statusNotification.CreditCardTransaction);
            Assert.IsNotNull(statusNotification.BoletoTransaction);
            Assert.AreEqual(Guid.Parse("B1B1092C-8681-40C2-A734-500F22683D9B"), statusNotification.MerchantKey);
            Assert.AreEqual(Guid.Parse("1025FCB5-41D8-43B5-82FE-398F61E83879"), statusNotification.OrderKey);
            Assert.AreEqual("9623472", statusNotification.OrderReference);
            Assert.AreEqual(OrderStatusEnum.Paid, statusNotification.OrderStatus);

            // BoletoTransaction
            Assert.AreEqual(1000, statusNotification.BoletoTransaction.AmountInCents);
            Assert.AreEqual(1000, statusNotification.BoletoTransaction.AmountPaidInCents);
            Assert.AreEqual(ParseDateTime("2015-09-21T15:42:04.573"), statusNotification.BoletoTransaction.BoletoExpirationDate);
            Assert.AreEqual("0123456789", statusNotification.BoletoTransaction.NossoNumero);
            Assert.AreEqual(ParseDateTime("2015-09-22T07:06:00.537"), statusNotification.BoletoTransaction.StatusChangedDate);
            Assert.AreEqual(Guid.Parse("F7C4B737-E8B5-4BAA-BB47-6ED2A1A1EE09"), statusNotification.BoletoTransaction.TransactionKey);
            Assert.AreEqual("6741137", statusNotification.BoletoTransaction.TransactionReference);
            Assert.AreEqual(BoletoTransactionStatusEnum.Generated, statusNotification.BoletoTransaction.PreviousBoletoTransactionStatus);
            Assert.AreEqual(BoletoTransactionStatusEnum.Paid, statusNotification.BoletoTransaction.BoletoTransactionStatus);

            // CreditCardTransaction
            CreditCardTransaction creditCardTransaction = statusNotification.CreditCardTransaction;

            Assert.AreEqual("Simulator", creditCardTransaction.Acquirer);
            Assert.AreEqual(500, creditCardTransaction.AmountInCents);
            Assert.AreEqual("123456", creditCardTransaction.AuthorizationCode);
            Assert.AreEqual(500, creditCardTransaction.AuthorizedAmountInCents);
            Assert.AreEqual(500, creditCardTransaction.CapturedAmountInCents);
            Assert.AreEqual("Mastercard", creditCardTransaction.CreditCardBrand);
            Assert.AreEqual("String Content", creditCardTransaction.CustomStatus);
            Assert.AreEqual(100, creditCardTransaction.RefundedAmountInCents);
            Assert.AreEqual(this.ParseDateTime("2015-09-22T15:51:41.217"), creditCardTransaction.StatusChangedDate);
            Assert.AreEqual("9876543210", creditCardTransaction.TransactionIdentifier);
            Assert.AreEqual(Guid.Parse("4111D523-9A83-4BE3-94D2-160F1BC9C4BD"), creditCardTransaction.TransactionKey);
            Assert.AreEqual("91735820", creditCardTransaction.TransactionReference);
            Assert.AreEqual("63417982", creditCardTransaction.UniqueSequentialNumber);
            Assert.AreEqual(100, creditCardTransaction.VoidedAmountInCents);
            Assert.AreEqual(CreditCardTransactionStatusEnum.AuthorizedPendingCapture, creditCardTransaction.PreviousCreditCardTransactionStatus);
            Assert.AreEqual(CreditCardTransactionStatusEnum.Captured, creditCardTransaction.CreditCardTransactionStatus);

            // OnlineDebitTransaction
            Assert.AreEqual(7000, statusNotification.OnlineDebitTransaction.AmountInCents);
            Assert.AreEqual(7000, statusNotification.OnlineDebitTransaction.AmountPaidInCents);
            Assert.AreEqual("BancoDoBrasil", statusNotification.OnlineDebitTransaction.BankName);
            Assert.AreEqual("22092015", statusNotification.OnlineDebitTransaction.BankPaymentDate);
            Assert.AreEqual(ParseDateTime("2015-09-22T13:15:46.333"), statusNotification.OnlineDebitTransaction.StatusChangedDate);
            Assert.AreEqual(Guid.Parse("751AE9F0-AF0B-4DE5-A483-2EFF2DE0FDF6"), statusNotification.OnlineDebitTransaction.TransactionKey);
            Assert.AreEqual("00000000000012345", statusNotification.OnlineDebitTransaction.TransactionKeyToBank);
            Assert.AreEqual("656885531", statusNotification.OnlineDebitTransaction.TransactionReference);
            Assert.AreEqual(OnlineDebitTransactionStatusEnum.OpenedPendingPayment, statusNotification.OnlineDebitTransaction.PreviousOnlineDebitTransactionStatus);
            Assert.AreEqual(OnlineDebitTransactionStatusEnum.Paid, statusNotification.OnlineDebitTransaction.OnlineDebitTransactionStatus);
        }
Beispiel #8
0
        protected override async Task Init()
        {
            NotificationParser = new NotificationParser(Config);

            JobQueueModule = await GetModuleAsync <JobQueueModule>();

            JobQueueModule.RegisterJob <Notification>(RespondNotification);

            await Cleanup();
        }
Beispiel #9
0
        private void BuildSyncManager()
        {
            try
            {
                // Synchronizer
                var impressionsCountSender = new ImpressionsCountSender(_impressionsSdkApiClient, _impressionsCounter, _tasksManager);
                var backOff      = new BackOff(backOffBase: 10, attempt: 0, maxAllowed: 60);
                var synchronizer = new Synchronizer(_splitFetcher, _selfRefreshingSegmentFetcher, _impressionsLog, _eventsLog, impressionsCountSender, _wrapperAdapter, _statusManager, _telemetrySyncTask, _tasksManager, _splitCache, backOff, _config.OnDemandFetchMaxRetries, _config.OnDemandFetchRetryDelayMs, _segmentCache);

                // Workers
                var splitsWorker   = new SplitsWorker(_splitCache, synchronizer, _tasksManager);
                var segmentsWorker = new SegmentsWorker(synchronizer, _tasksManager);

                // NotificationProcessor
                var notificationProcessor = new NotificationProcessor(splitsWorker, segmentsWorker);

                // NotificationParser
                var notificationParser = new NotificationParser();

                // NotificationManagerKeeper
                var notificationManagerKeeper = new NotificationManagerKeeper(_telemetryRuntimeProducer);

                // EventSourceClient
                var headers = GetHeaders();
                headers.Add(Constants.Http.SplitSDKClientKey, ApiKey.Substring(ApiKey.Length - 4));
                headers.Add(Constants.Http.Accept, Constants.Http.EventStream);
                var sseHttpClient     = new SplitioHttpClient(ApiKey, _config.HttpConnectionTimeout, headers);
                var eventSourceClient = new EventSourceClient(notificationParser, _wrapperAdapter, sseHttpClient, _telemetryRuntimeProducer, _tasksManager);

                // SSEHandler
                var sseHandler = new SSEHandler(_config.StreamingServiceURL, splitsWorker, segmentsWorker, notificationProcessor, notificationManagerKeeper, eventSourceClient: eventSourceClient);

                // AuthApiClient
                var httpClient    = new SplitioHttpClient(ApiKey, _config.HttpConnectionTimeout, GetHeaders());
                var authApiClient = new AuthApiClient(_config.AuthServiceURL, ApiKey, httpClient, _telemetryRuntimeProducer);

                // PushManager
                var backoff     = new BackOff(_config.AuthRetryBackoffBase, attempt: 1);
                var pushManager = new PushManager(sseHandler, authApiClient, _wrapperAdapter, _telemetryRuntimeProducer, backoff);

                // SyncManager
                _syncManager = new SyncManager(_config.StreamingEnabled, synchronizer, pushManager, sseHandler, notificationManagerKeeper, _telemetryRuntimeProducer, _statusManager, _tasksManager, _wrapperAdapter, _telemetrySyncTask);
            }
            catch (Exception ex)
            {
                _log.Error($"BuildSyncManager: {ex.Message}");
            }
        }
        public async Task ParseNotifcation(
            [Summary("See examples for proper syntax.")] params string[] input)
        {
            string name = (Message.Author as IGuildUser)?.Nickname ?? Message.Author.Username;

            if (!NotificationParser.TryParse(input, name, out NotificationJob job))
            {
                await RespondAsync("Invalid input.", false, false);

                return;
            }

            await JobModule.AddJobAsync(job);

            DateTime time = JobModule.GetNextCall(job);

            await RespondAsync($"Notification added for: {time.ToString(Config.OutputTimeFormat)} to {string.Join(',', job.Channels)}", false, false);
        }
Beispiel #11
0
        public void EventSourceClient_IncorrectFormat_ShouldReceiveError()
        {
            using (var httpClientMock = new HttpClientMock())
            {
                httpClientMock.SSE_Channels_Response(
                    @"{ 'event': 'message', 
                        'data': {
                            'id':'1',
                            'channel':'mauroc',
                            'content': {
                                'type': 'CONTROL', 
                                'controlType': 'test-control-type'
                            },
                            'name':'name-test'
                         }
                        }");

                var url            = httpClientMock.GetUrl();
                var eventsReceived = new BlockingCollection <EventReceivedEventArgs>(new ConcurrentQueue <EventReceivedEventArgs>());
                var actionEvent    = new BlockingCollection <SSEActionsEventArgs>(new ConcurrentQueue <SSEActionsEventArgs>());

                var notificationParser       = new NotificationParser();
                var wrapperAdapter           = new WrapperAdapter();
                var sseHttpClient            = new SplitioHttpClient("api-key", 5000);
                var telemetryRuntimeProducer = new InMemoryTelemetryStorage();

                var eventSourceClient = new EventSourceClient(notificationParser, wrapperAdapter, sseHttpClient, telemetryRuntimeProducer, new TasksManager(wrapperAdapter));
                eventSourceClient.EventReceived += delegate(object sender, EventReceivedEventArgs e)
                {
                    eventsReceived.TryAdd(e);
                };
                eventSourceClient.ActionEvent += delegate(object sender, SSEActionsEventArgs e)
                {
                    actionEvent.TryAdd(e);
                };
                eventSourceClient.ConnectAsync(url);

                actionEvent.TryTake(out SSEActionsEventArgs action, 10000);
                Assert.AreEqual(SSEClientActions.CONNECTED, action.Action);
                Assert.AreEqual(0, eventsReceived.Count);
            }
        }
Beispiel #12
0
        private void BuildSyncManager()
        {
            try
            {
                var synchronizer              = new Synchronizer(_splitFetcher, _selfRefreshingSegmentFetcher, _impressionsLog, _eventsLog, _metricsLog, _wrapperAdapter);
                var splitsWorker              = new SplitsWorker(_splitCache, synchronizer);
                var segmentsWorker            = new SegmentsWorker(_segmentCache, synchronizer);
                var notificationProcessor     = new NotificationProcessor(splitsWorker, segmentsWorker);
                var notificationParser        = new NotificationParser();
                var eventSourceClient         = new EventSourceClient(_config.StreamingReconnectBackoffBase, notificationParser: notificationParser);
                var notificationManagerKeeper = new NotificationManagerKeeper();
                var sseHandler    = new SSEHandler(_config.StreamingServiceURL, splitsWorker, segmentsWorker, notificationProcessor, notificationManagerKeeper, eventSourceClient: eventSourceClient);
                var authApiClient = new AuthApiClient(_config.AuthServiceURL, ApiKey, _config.HttpReadTimeout);
                var pushManager   = new PushManager(_config.AuthRetryBackoffBase, sseHandler, authApiClient, _wrapperAdapter);

                _syncManager = new SyncManager(_config.StreamingEnabled, synchronizer, pushManager, sseHandler, notificationManagerKeeper);
            }
            catch (Exception ex)
            {
                _log.Error($"BuildSyncManager: {ex.Message}");
            }
        }
        public void ParseNotification_CreditCard_Test()
        {
            NotificationParser notificationParser = new NotificationParser();

            StatusNotification statusNotification = null;

            statusNotification = notificationParser.ParseNotification(this.creditCardNotification);

            Assert.AreEqual(500, statusNotification.AmountInCents);
            Assert.AreEqual(500, statusNotification.AmountPaidInCents);
            Assert.IsNotNull(statusNotification.CreditCardTransaction);
            Assert.IsNull(statusNotification.OnlineDebitTransaction);
            Assert.AreEqual(Guid.Parse("B1B1092C-8681-40C2-A734-500F22683D9B"), statusNotification.MerchantKey);
            Assert.AreEqual(Guid.Parse("18471F05-9F6D-4497-9C24-D60D5BBB6BBE"), statusNotification.OrderKey);
            Assert.AreEqual("64a85875", statusNotification.OrderReference);
            Assert.AreEqual(OrderStatusEnum.Paid, statusNotification.OrderStatus);

            // CreditCardTransaction
            CreditCardTransaction creditCardTransaction = statusNotification.CreditCardTransaction;

            Assert.AreEqual("Simulator", creditCardTransaction.Acquirer);
            Assert.AreEqual(500, creditCardTransaction.AmountInCents);
            Assert.AreEqual("123456", creditCardTransaction.AuthorizationCode);
            Assert.AreEqual(500, creditCardTransaction.AuthorizedAmountInCents);
            Assert.AreEqual(500, creditCardTransaction.CapturedAmountInCents);
            Assert.AreEqual("Mastercard", creditCardTransaction.CreditCardBrand);
            Assert.IsTrue(string.IsNullOrEmpty(creditCardTransaction.CustomStatus));
            Assert.IsNull(creditCardTransaction.RefundedAmountInCents);
            Assert.AreEqual(this.ParseDateTime("2015-09-22T15:51:41.217"), creditCardTransaction.StatusChangedDate);
            Assert.AreEqual("9876543210", creditCardTransaction.TransactionIdentifier);
            Assert.AreEqual(Guid.Parse("4111D523-9A83-4BE3-94D2-160F1BC9C4BD"), creditCardTransaction.TransactionKey);
            Assert.AreEqual("91735820", creditCardTransaction.TransactionReference);
            Assert.AreEqual("63417982", creditCardTransaction.UniqueSequentialNumber);
            Assert.IsNull(creditCardTransaction.VoidedAmountInCents);
            Assert.AreEqual(CreditCardTransactionStatusEnum.AuthorizedPendingCapture, creditCardTransaction.PreviousCreditCardTransactionStatus);
            Assert.AreEqual(CreditCardTransactionStatusEnum.Captured, creditCardTransaction.CreditCardTransactionStatus);
        }
Beispiel #14
0
 /// <summary>
 /// Parse user input to notification
 /// </summary>
 /// <param name="input"></param>
 /// <param name="author"></param>
 /// <returns></returns>
 public Notification Parse(string[] input, string author)
 {
     return(NotificationParser.Parse(input, author));
 }