Пример #1
0
        public void UpdateUserCustomerRelationship_GivenPayload_ExpectedStatus(
            UpdateUserCustomerRelationshipEvent relationshipEvent, bool transactionStatus, int upsertCalls,
            int publishCalls, bool hasException)
        {
            //Arrange
            if (hasException)
            {
                transaction.When(x => x.Publish(Arg.Any <List <KafkaMessage> >()))
                .Do(x => throw new Exception());
            }

            if (hasException)
            {
                Assert.Throws <Exception>(() => customerService.UpdateUserCustomerRelationship(relationshipEvent));
            }
            else
            {
                var resultData = customerService.UpdateUserCustomerRelationship(relationshipEvent);

                Assert.Equal(transactionStatus, resultData);
            }
            //Act

            transaction.Received(upsertCalls).Upsert(Arg.Any <DbUserCustomer>());
            transaction.Received(publishCalls).Publish(Arg.Is <List <KafkaMessage> >(messages => messages
                                                                                     .TrueForAll(m => ValidateCustomerUserKafkaObject(false, true, m, relationshipEvent))));
        }