public async Task Handle_ErrorMessageFromXmg_ShouldRejectCost(ResponseErrorType errorType)
        {
            // Arrange
            var cost = MockCost();

            var payload = new { errorMessages = new[] { new { type = ((int)errorType).ToString(), message = "Error messages" } } };

            var message = new PurchaseOrderErrorResponse
            {
                ActivityType   = "Error",
                ClientName     = BuType.Pg.ToString(),
                EventTimeStamp = DateTime.Now,
                CostNumber     = cost.CostNumber,
                Payload        = JObject.Parse(JsonConvert.SerializeObject(payload))
            };
            var response = new ApprovalServiceActionResult {
                Success = true, ApprovalType = "Brand"
            };

            var costUser = new CostUser {
                GdamUserId = "alsjdnaljsdn"
            };
            var adminUser = new CostUser {
                Email = ApprovalMemberModel.BrandApprovalUserEmail
            };
            var adminUserIdentity = new SystemAdminUserIdentity(adminUser);

            var costUserSetMock = _efContextMock.MockAsyncQueryable(new List <CostUser> {
                costUser, adminUser
            }.AsQueryable(), context => context.CostUser);

            costUserSetMock.Setup(u => u.FindAsync(It.IsAny <Guid>())).ReturnsAsync(costUser);

            _approvalServiceMock.Setup(a => a.Reject(cost.Id, adminUserIdentity, BuType.Pg, "Error messages", SourceSystem.Coupa)).ReturnsAsync(response);

            // Act
            await _handler.Handle(message);

            // Assert
            _approvalServiceMock.Verify(s => s.Reject(cost.Id, adminUserIdentity, BuType.Pg, "Error messages", SourceSystem.Coupa));
        }
        public async Task Handle_WhenTechnicalError_ShouldSendEmailToSupportTeam()
        {
            // Arrange
            var costNumber = "12345";

            var payload = new { errorMessages = new[] { new { type = ((int)ResponseErrorType.Technical).ToString(), message = "Error messages" } } };

            var message = new PurchaseOrderErrorResponse
            {
                ActivityType   = "Error",
                ClientName     = BuType.Pg.ToString(),
                EventTimeStamp = DateTime.Now,
                CostNumber     = costNumber,
                Payload        = JObject.Parse(JsonConvert.SerializeObject(payload))
            };

            // Act
            await _handler.Handle(message);

            // Assert
            _supportNotificationService.Verify(ens => ens.SendSupportErrorNotification(It.IsAny <string>(), It.IsAny <string>(), null),
                                               Times.Once);
        }