Exemplo n.º 1
0
        public void ThrowEndPointNotFoundExceptionWithValidBulkregistrationRequest_ShouldLogFailedTransmission()
        {
            var techModel     = new TechModelOne(_sovosContractor.CspCode);
            var bulkOperation = new BulkOperationNew(EntityType.LL.ToString(), "123456", _physicalUsaAddress, _contactSellerInfo, techModel)
            {
                MailingAddress = _mailUsaAddress
            };

            foreach (var state in _sstStates)
            {
                bulkOperation.RegistrationIndicatorItems.Add(new BulkNewRegistrationIndicatorOperation(state, "R", DateTime.UtcNow, "Y", "Y")
                {
                    RemoteEffectiveDate = DateTime.UtcNow
                });
            }
            var seller = new FeinTaxpayer(_sovosContractor, bulkOperation, "12345678", "Walmart", StateType.TN.ToString(), "1234567890", "Sovos1234");

            var user = new User("regulatory-analisys", "Sovos1234!");

            _root.AddUser(user, _genericRepository, new UserRepository());

            var mockEnvironment = new TransmittalEnvironment("Mock service", "dummy-endpoint", "mock", "Sovos1234!", "v1", ETransmissionMode.OnlyValidate)
            {
                SetupMockParameters = new ServiceMockParameters {
                    ThrowEndpointNotFoundException = true
                }
            };
            var transmitter = new SstRegistrationTransmitter(_sovosContractor, mockEnvironment);
            var manager     = new SimplifiedElectronicReturnManager(transmitter, user, _root, _genericRepository);

            var response = manager.SubmitTaxpayerData(new List <Taxpayer> {
                seller
            });

            Assert.IsTrue(response.HasErrors);
            Assert.IsNotNull(response.ContentSent);
            Assert.IsNull(response.ContentReceived);
            Assert.IsNotNull(response.OriginalResponse);

            var logs = _genericRepository.ListAll <TransmittalLog>();

            Assert.AreEqual(1, _genericRepository.Count <TransmittalLog>());

            var log = logs.ElementAt(0);

            Assert.AreEqual(ETransmittalStatus.Rejected, log.TransmissionStatus);
            Assert.IsNotNull(log.ContentSent);

            foreach (var item in log.LogItems)
            {
                Assert.AreEqual(ETransmittalStatus.Rejected, item.DocumentStatus);
                Assert.AreEqual("Endpoint not found exception.", item.Errors);
            }
        }
Exemplo n.º 2
0
        public void SubmitValidNewBulkRegistrationRequest_ShouldLogSuccessfulyTransmission()
        {
            var techModel     = new TechModelOne(_sovosContractor.CspCode);
            var bulkOperation = new BulkOperationNew(EntityType.LL.ToString(), "123456", _physicalUsaAddress, _contactSellerInfo, techModel)
            {
                MailingAddress = _mailUsaAddress
            };

            foreach (var state in _sstStates)
            {
                bulkOperation.RegistrationIndicatorItems.Add(new BulkNewRegistrationIndicatorOperation(state, "R", DateTime.UtcNow, "Y", "Y")
                {
                    RemoteEffectiveDate = DateTime.UtcNow
                });
            }

            var seller1  = new FeinTaxpayer(_sovosContractor, bulkOperation, "12345678", "Walmart", StateType.TN.ToString(), "1234567890", "Sovos1234");
            var seller2  = new FeinTaxpayer(_sovosContractor, bulkOperation, "12345678", "Sears", StateType.TN.ToString(), "1234567890", "Sovos1234");
            var seller3  = new FeinTaxpayer(_sovosContractor, bulkOperation, "12345678", "Starbucks", StateType.TN.ToString(), "1234567890", "Sovos1234");
            var response = _manager.SubmitTaxpayerData(new List <Taxpayer> {
                seller1, seller2, seller3
            });

            Assert.IsFalse(response.HasErrors);
            Assert.IsNotNull(response.ContentSent);
            Assert.IsNotNull(response.ContentReceived);
            Assert.IsNotNull(response.OriginalResponse);

            var logs = _genericRepository.ListAll <TransmittalLog>();

            Assert.AreEqual(1, logs.Count <TransmittalLog>());

            var log = logs.ElementAt(0);

            Assert.AreEqual(response.ContentSent, log.ContentSent);
            Assert.AreEqual(response.ContentReceived, log.ContentReceived);
            Assert.AreEqual(ETransmittalStatus.Approved, log.TransmissionStatus);
            Assert.AreEqual(response.OriginalResponse.TransmissionAcknowledgement.TransmissionId, log.TransmissionId);
            Assert.AreEqual("admin", log.Submitter.Username);
            Assert.AreEqual(ETransmissionMode.OnlyValidate, log.TransmissionMode);
            Assert.AreEqual("dummy-endpoint", log.EndpointUrl);

            Assert.AreEqual(3, log.LogItems.Count);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[0].DocumentId, log.LogItems.ElementAt(0).DocumentId);
            Assert.AreEqual(ETransmittalStatus.Approved, log.LogItems.ElementAt(0).DocumentStatus);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[0].SSTPID, log.LogItems.ElementAt(0).SstpId);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[0].Errors, log.LogItems.ElementAt(0).Errors);
            Assert.IsNull(log.LogItems.ElementAt(0).Errors);

            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[1].DocumentId, log.LogItems.ElementAt(1).DocumentId);
            Assert.AreEqual(ETransmittalStatus.Approved, log.LogItems.ElementAt(1).DocumentStatus);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[1].SSTPID, log.LogItems.ElementAt(1).SstpId);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[1].Errors, log.LogItems.ElementAt(1).Errors);
            Assert.IsNull(log.LogItems.ElementAt(1).Errors);

            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[2].DocumentId, log.LogItems.ElementAt(2).DocumentId);
            Assert.AreEqual(ETransmittalStatus.Approved, log.LogItems.ElementAt(2).DocumentStatus);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[2].SSTPID, log.LogItems.ElementAt(2).SstpId);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[2].Errors, log.LogItems.ElementAt(2).Errors);
            Assert.IsNull(log.LogItems.ElementAt(2).Errors);

            var seller4 = new SsnTaxPayer(_sovosContractor, bulkOperation, "87654321", "Lionel", "Messi", StateType.FL.ToString(), "0987654321", "Sovos1234");
            var seller5 = new SsnTaxPayer(_sovosContractor, bulkOperation, "87654321", "Roger", "Federer", StateType.FL.ToString(), "0987654321", "Sovos1234");

            response = _manager.SubmitTaxpayerData(new List <Taxpayer> {
                seller4, seller5
            });

            Assert.IsFalse(response.HasErrors);
            Assert.IsNotNull(response.ContentSent);
            Assert.IsNotNull(response.ContentReceived);
            Assert.IsNotNull(response.OriginalResponse);

            logs = _genericRepository.ListAll <TransmittalLog>();
            Assert.AreEqual(2, _genericRepository.Count <TransmittalLog>());

            log = logs.ElementAt(1);
            Assert.AreEqual(response.ContentSent, log.ContentSent);
            Assert.AreEqual(response.ContentReceived, log.ContentReceived);
            Assert.AreEqual(ETransmittalStatus.Approved, log.TransmissionStatus);
            Assert.AreEqual(response.OriginalResponse.TransmissionAcknowledgement.TransmissionId, log.TransmissionId);
            Assert.AreEqual("admin", log.Submitter.Username);
            Assert.AreEqual(ETransmissionMode.OnlyValidate, log.TransmissionMode);
            Assert.AreEqual("dummy-endpoint", log.EndpointUrl);

            Assert.AreEqual(2, log.LogItems.Count);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[0].DocumentId, log.LogItems.ElementAt(0).DocumentId);
            Assert.AreEqual(ETransmittalStatus.Approved, log.LogItems.ElementAt(0).DocumentStatus);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[0].SSTPID, log.LogItems.ElementAt(0).SstpId);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[0].Errors, log.LogItems.ElementAt(0).Errors);
            Assert.IsNull(log.LogItems.ElementAt(0).Errors);

            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[1].DocumentId, log.LogItems.ElementAt(1).DocumentId);
            Assert.AreEqual(ETransmittalStatus.Approved, log.LogItems.ElementAt(1).DocumentStatus);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[1].SSTPID, log.LogItems.ElementAt(1).SstpId);
            Assert.AreEqual(response.OriginalResponse.BulkRegAcknowledgement[1].Errors, log.LogItems.ElementAt(1).Errors);
            Assert.IsNull(log.LogItems.ElementAt(1).Errors);
        }