Пример #1
0
            public void RunTaskExecutesSuccessfullyFirstTime()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    IBusinessManager businessManager = new BusinessManager();
                    DateTime fromDate = new DateTime(2012, 01, 1, 0, 0, 0, DateTimeKind.Utc);
                    SyncBusinessesToEagle.FromDate = fromDate;
                    SyncBusinessesToEagle.Identity = new GenericIdentity(WindowsServiceUserGuid.ToString());
                    //UserHelper.SetupUser(WindowsUserName, UserHelper.VALIDUSERPASS, WindowsUserName, WindowsServiceUserGuid);
                    List<EcomBusinessAccount> expectedBusinessAccountList = new EcomDataProvider().GetLastModifiedBusinesses(fromDate, DateTime.UtcNow);

                    // Act
                    SyncBusinessesToEagle.Run();

                    // Assert
                    //verify if the latest timestamp in Eccom.BusinessAccount is later than the one obtained before
                    DateTime lastModifiedDateTime = businessManager.GetTimestampOfLastBusinessSyncedFromEcom();

                    // Add 10 seconds to date time now so it doesn't fail in the build server
                    var now = DateTime.UtcNow.AddSeconds(10);

                    TimeSpan currentDateDiff = now - lastModifiedDateTime;
                    TimeSpan lastDateDiff = lastModifiedDateTime - fromDate;
                    bool result = (currentDateDiff.TotalHours >= 0 && lastDateDiff.TotalHours >= 0);
                    Assert.IsTrue(result, string.Format("The last modified date is not correct: lastModifiedDateTime - {0} ; fromDate - {1}. Now: {2}", lastModifiedDateTime, fromDate, now));

                    //verify if all the expected businesses were inserted/updated
                    Assert.AreEqual(expectedBusinessAccountList.Count, businessManager.GetBusinessAccountsSyncedByLastModifiedDate(lastModifiedDateTime).Count, "The expected businesses were not returned.");
                }
            }
Пример #2
0
            public void VerifyShortNameIsUnique()
            {
                using (
                    new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA,
                                       DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    const string SHORT_NAME = "Test242635";

                    // Act
                    var isUnique = new EcomDataProvider().VerifyShortNameIsUnique(SHORT_NAME);

                    // Assert
                    Assert.IsTrue(isUnique, "The shortname is unique");
                }
            }
Пример #3
0
            public void VerifyShortNameIsNotUnique()
            {
                using (
                    new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA,
                                       DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    var ecomDataProvider = new EcomDataProvider();

                    // Arrange
                    // obtain an existing shortname from the ecom database
                    string shortName = ecomDataProvider.GetFirstShortnameInList();

                    // Act
                    var isUnique = ecomDataProvider.VerifyShortNameIsUnique(shortName);

                    // Assert
                    Assert.IsFalse(isUnique, "The shortname is not unique");
                    Assert.IsNotNull(shortName, "A short name must have been found to verify this test");
                }
            }
Пример #4
0
            public void RunTaskFirstTimeCreatesBusinessesInEcom()
            {

                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    DateTime startTime = DateTime.UtcNow.AddSeconds(-5);
                    syncBusinessesToEcom.Identity = new GenericIdentity(WindowsServiceUserGuid.ToString());

                    // Act
                    syncBusinessesToEcom.Run();

                    // Assert
                    bool isOptin = new EcomDataProvider().HasBusinessEcommOptInForThisChannel("Bus1", "toprooms");
                    Assert.IsTrue(isOptin, "Business failed to optin to the imported channel");
                    DateTime endTime = DateTime.Now.AddSeconds(5);
                    var businessUpdateTime = new EcomDataProvider().GetMostRecentBusinessUpdateTime();

                    TimeSpan startDateDiff = startTime - businessUpdateTime;
                    TimeSpan endDateDiff = businessUpdateTime - endTime;
                    bool result = (startDateDiff.TotalSeconds <= 0 && endDateDiff.TotalSeconds <= 0);
                    Assert.IsTrue(result, string.Format("Businesses have not being copied to Ecom: startTime - {0} ; endTime - {1} ; businessUpdateTime: {2}", startTime, endTime, businessUpdateTime));
                 }
            }
Пример #5
0
            public void GetPaymentOptionsForDistributorReturnsInvalidPaymentMappingOption()
            {
                const string CHANNEL_SHORTNAME = "TopRooms_EUR";

                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    var paymentOption = new EcomDataProvider().GetPaymentOptionsForDistributor(CHANNEL_SHORTNAME);

                    Assert.IsTrue(!paymentOption.HasValue, "Invalid payment options returned");
                }
            }
Пример #6
0
            public void VerifyContentIdIsUniqueForNullShortName()
            {
                using (
                    new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA,
                                       DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    string contentId = "Test242635";

                    // Act
                    var isUnique = new EcomDataProvider().VerifyContentIdIsUnique(null, contentId);

                    // Assert
                    Assert.IsTrue(isUnique, "The ContentId is unique");
                }
            }
Пример #7
0
            public void GetPaymentOptionsForDistributorReturnsCorrectPaymentMappingOption()
            {
                const int EXPECTED_PAYMENT_OPTION = 11;
                const string CHANNEL_SHORTNAME = "TopRooms";

                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    var paymentOption = new EcomDataProvider().GetPaymentOptionsForDistributor(CHANNEL_SHORTNAME);

                    Assert.AreEqual(EXPECTED_PAYMENT_OPTION, paymentOption.Value, "Invalid payment options returned");
                }
            }
Пример #8
0
            public void VerifyContentIdIsUniqueWhenUsingBusinessId()
            {
                using (
                    new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA,
                                       DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange    
                    string shortName = "Bus3";
                    string contentId = "1002";

                    // Act
                    var isUnique = new EcomDataProvider().VerifyContentIdIsUnique(shortName, contentId);

                    // Assert
                    Assert.IsTrue(isUnique, "The ContentId expected to be unique");
                }
            }
Пример #9
0
        public override void ExecuteTask()
        {
            foreach (ServiceTaskProviderElement provider in ServiceTaskProviderConfiguration.ProviderConfiguration)
            {
                ecomDataProvider = new EcomDataProvider(provider.ConnectionString);

                if (!ecomDataProvider.EagleExistsAsExternalSupplier())
                {
                    Log.LogInfo(
                        "Eagle doesn't exist in Ecom as an external supply partner. None of the businesses will be synced");
                }
                else
                {
                    // Get the last updated timestamp from ECOM for Eagle businesses
                    DateTime mostRecentUpdateTime = ecomDataProvider.GetMostRecentBusinessUpdateTime();

                    Log.LogInfo(string.Format("Getting businesses updated from {0}",
                                              mostRecentUpdateTime.ToString(CultureInfo.InvariantCulture)));

                    // Get all businesses in Eagle modified since this date and are associated to countries for this provider (Eagle.Business.Updated >=) - if first run assume 2013-01-01
                    List<Model.Business.Business> businesses =
                        businessManager.GetLastModifiedBusinesses(mostRecentUpdateTime)
                                       .Where(c => provider.ContainsCountry(c.Country.IsoChar2Code))
                                       .ToList();

                    Log.LogInfo(string.Format("{0} {1} Businesses have been modified on Eagle", businesses.Count,
                                              provider.ProviderSet));
                    int numberOfBusinessesSynced = 0;

                    //  Insert/Update records in the ECOM database
                    if (Log.IsDebugEnabled)
                    {
                        Log.LogDebug(string.Format("Synchronizing {0} businesses to Ecom:", provider.ProviderSet));
                    }
                    Guid updatedByUserId;
                    if (!Guid.TryParse(identity.Name, out updatedByUserId))
                    {
                        Log.LogError("Couldn't get the user identity from the current thread");
                        Log.LogInfo("Synchronizing task finished executing");
                        return;
                    }

                    foreach (Model.Business.Business business in businesses)
                    {
                        if (State == TaskState.Stopping)
                        {
                            Log.LogInfo("Aborting SyncBusinessesToEcom task due to the service being stopped.");
                            return;
                        }

                        List<string> missedChannels;
                        var businessAccount = EcomConverter.EagleBusinessToEcom(business, provider.ChannelSyncCode,
                                                                                out missedChannels);
                        businessAccount.ModifiedByUserId = updatedByUserId;
                        businessAccount.ModifiedDate = DateTime.UtcNow;
                        businessAccount.BusinessAccountStatusTypeId = EcomConverter.ACTIVE_CODE;

                        bool synced = true;
                        EcomBusinessInfo ecomBusinessInfo = null;
                        try
                        {
                            ecomBusinessInfo = ecomDataProvider.SaveBusinessAccount(businessAccount);
                            Log.LogDebug(string.Format("businessId = {0} synced", business.Id));
                        }
                        catch (SqlException ex)
                        {
                            Log.LogError(
                                string.Format("businessId = {0} was not synced because of SQL error.", business.Id),
                                ex: ex);
                            synced = false;
                        }


                        if (Log.IsDebugEnabled && synced)
                        {
                            numberOfBusinessesSynced++;

                            if (ecomBusinessInfo != null)
                            {
                                Log.LogDebug(string.Format("businessId = {0} Channels synced    : {1}", business.Id,
                                                           ecomBusinessInfo.AddedChannels.ToArray().Serialize()));
                                Log.LogDebug(string.Format("businessId = {0} Channels missed    : {1}{2}", business.Id,
                                                           ecomBusinessInfo.MissingChannels.ToArray().Serialize(),
                                                           missedChannels.ToArray().Serialize()));
                            }

                            Log.LogDebug(string.Format("businessId = {0} synced", business.Id));
                        }
                    }

                    Log.LogInfo(string.Format("{0} {1} Businesses have been synced to Ecom", numberOfBusinessesSynced,
                                              provider.ProviderSet));
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Particular execute 
        /// </summary>
        public override void ExecuteTask()
        {
            //Get the last sync timestamp from Ecommerce.BusinessAccount 
            DateTime lastModifiedDateTime = businessManager.GetTimestampOfLastBusinessSyncedFromEcom();

            if (fromDate.HasValue)
            {
                //means that we are unit testing it so we need to assume that this is the last modified date
                lastModifiedDateTime = fromDate.Value;
            }


            Log.LogInfo("Getting businesses updated from {0}", null,  lastModifiedDateTime.ToString(CultureInfo.InvariantCulture));

            foreach (ServiceTaskProviderElement provider in ServiceTaskProviderConfiguration.ProviderConfiguration)
            {
                ecomDataProvider = new EcomDataProvider(provider.ConnectionString);

                //Get all business modified since this timestamp in Ecommerce (BA_BUSINESSACCOUNT.BABA_MODIFICATIONDATE) 
                List<EcomBusinessAccount> ecomBusinessList = ecomDataProvider.GetLastModifiedBusinesses(lastModifiedDateTime, DateTime.UtcNow);
                if (ecomBusinessList != null)
                {
                    Log.LogInfo("{0} - {1} {2} Businesses have been modified on Ecom", null, TaskName, ecomBusinessList.Count, provider.ProviderSet);
                    int numberOfBusinessesSynced = 0;
                    //Insert/Update all modified businesses 
                    using (var tx = new BusinessTransaction())
                    {
                        if (Log.IsDebugEnabled)
                        {
                            Log.LogDebug(string.Format("Synchronizing businesses to Eagle:"));
                        }
                        Guid updatedByUserId;
                        if (!Guid.TryParse(identity.Name, out updatedByUserId))
                        {
                            tx.Rollback();
                            Log.LogError("Couldn't get the user identity from the current thread");
                            Log.LogInfo("SyncBusinessesToEagle task finished executing");
                            return;
                        }

                        foreach (EcomBusinessAccount ecomBusinessAccount in ecomBusinessList)
                        {
                            if (State == TaskState.Stopping)
                            {
                                tx.Rollback();
                                Log.LogInfo("Aborting SyncBusinessesToEagle task due to the service being stopped.");
                                return;
                            }

                            ecomBusinessAccount.ModifiedByUserId = updatedByUserId;

                            var synced = true;
                            try
                            {
                                //Log error in case we were unable to save due to existing ShortName in Business.BusinessCombined table
                                if (!businessManager.SaveEcomBusinessAccount(EcomConverter.ConvertEcomToEagle(ecomBusinessAccount)))
                                {
                                    synced = false;
                                    Log.LogError("eccomId = {0} was not synced because of existing shortName ({1}) in Business.BusinessCombined", null, null, ecomBusinessAccount.Id, ecomBusinessAccount.ShortName);
                                }
                            }
                            catch (SqlException ex)
                            {
                                Log.LogError("eccomId = {0} was not synced because of SQL error.", null, ex, ecomBusinessAccount.Id);
                                synced = false;
                            }

                            if (!synced)
                            {
                                continue;
                            }

                            numberOfBusinessesSynced++;

                            if (Log.IsDebugEnabled)
                            {
                                Log.LogDebug("eccomId = {0} synced", ecomBusinessAccount.Id);
                            }
                        }
                        tx.Commit();
                    }
                    Log.LogInfo("{0} {1} Businesses have been synced to Eagle", null, numberOfBusinessesSynced, provider.ProviderSet);
                }
            }
        }
Пример #11
0
 public void ThenThereShouldnBeBusinessInEcomWithEagleAsExternalProviderSupplier(int numberOfBusinesses)
 {
     List<EcomBusinessAccount> eagleBusinessesInEcom = new EcomDataProvider().GetLastModifiedEagleBusinesses(SqlDateTime.MinValue.Value, DateTime.Now);
     Assert.AreEqual(numberOfBusinesses, eagleBusinessesInEcom.Count);
 }
Пример #12
0
            public void GetLastModifiedBusinessesReturnsPositiveResult()
            {
                // Arrange
                DateTime expectedStartDate = new DateTime(2012, 01, 01);
                DateTime expectedEndDate = new DateTime(2012, 12, 31);

                // Act
                var businessAccountList = new EcomDataProvider().GetLastModifiedBusinesses(expectedStartDate, expectedEndDate);

                // Assert
                Assert.IsNotNull(businessAccountList, "The list returned is not expected to be null.");
                businessAccountList.ForEach(u => Assert.IsTrue(u.ModifiedDate.IsBetweenInclusive(expectedStartDate.AddDays(1), expectedEndDate), "Business account {0} modified date {1} is not in expected date range.", u.Id, u.ModifiedDate));
            }
Пример #13
0
            public void EagleExistsAsExternalSupplierReturnsFalseWhenExistsInDatabase()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA,
                    DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Act
                    bool result = new EcomDataProvider().EagleExistsAsExternalSupplier();

                    // Assert
                    Assert.IsTrue(result, "Eagle should exist in the Ecom database as supplier");
                }
            }
Пример #14
0
            public void HasBusinessOptInForThisChannelReturnsFalse()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {

                    //Arrange
                    const string BUSINESS_SHORT_NAME = "Bus1";
                    const string CHANNEL_SHORT_NAME =  "";

                    // Act
                    bool isOptin = new EcomDataProvider().HasBusinessEcommOptInForThisChannel(BUSINESS_SHORT_NAME, CHANNEL_SHORT_NAME);

                    // Assert
                    Assert.IsFalse(isOptin, "The Business is expected to not have optin for this channel.");
                }
            }
Пример #15
0
            public void GetChannelIdReturnsNull()
            {
                //Arrange
                const string SHORT_NAME = "34534534fsdfwer2$$%%";

                // Act
                string channelId = new EcomDataProvider().GetChannelId(SHORT_NAME);

                // Assert
                Assert.IsNull(channelId, "The channel is expected to be not found.");
            }
Пример #16
0
            public void GetChannelIdReturnsValidGuid()
            {
                //Arrange
                using (new TestDataHelper(TestQueryEcom.POPULATE_CHANNELS, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    const string SHORT_NAME = "TopRooms";

                    // Act
                    string channelId = new EcomDataProvider().GetChannelId(SHORT_NAME);

                    // Assert
                    Assert.IsNotNull(channelId, "The channel is expected to be found.");
                }
            }
Пример #17
0
            public void GetLastModifiedBusinessesWithValidRangeReturnsNothing()
            {
                // Arrange
                DateTime expectedStartDate = new DateTime(2012, 01, 01);
                DateTime expectedEndDate = new DateTime(2012, 01, 02);

                // Act
                var businessAccountList = new EcomDataProvider().GetLastModifiedBusinesses(expectedStartDate, expectedEndDate);

                // Assert
                Assert.IsEmpty(businessAccountList, "The list returned is expected to be empty.");
            }
Пример #18
0
            public void GetLastModifiedBusinessesWithSameDateOnRangeReturnsBusinesses()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    var startDate = new DateTime(2000, 02, 01, 0, 0, 0);
                    var endDate = new DateTime(2030, 02, 01, 0, 0, 0);
                    const int EXPECTED_BUSINESSES = 4;

                    // Act
                    var businessAccountList = new EcomDataProvider().GetLastModifiedBusinesses(startDate, endDate);

                    // Assert
                    Assert.IsNotNull(businessAccountList, "The list returned is not expected to be null.");
                    Assert.AreEqual(EXPECTED_BUSINESSES, businessAccountList.Count, "The number of businesses returned is not the expected");
                }
            }
Пример #19
0
            public void EagleExistsAsExternalSupplierReturnsFalseWhenIsNotInDatabase()
            {
                // Act
                bool result = new EcomDataProvider().EagleExistsAsExternalSupplier();

                // Assert
                Assert.IsFalse(result, "Eagle shouldn't exist in the Ecom database as supplier");
            }
Пример #20
0
            public void IsBusinessPresentReturnsTrue()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA,DbHelper.ECOM_CONNECTION_STRING_NAME))
                {

                    //Arrange
                    const string BUSINESS_SHORT_NAME = "Bus1";

                    // Act
                    bool bResult = new EcomDataProvider().IsBusinessPresent(BUSINESS_SHORT_NAME);

                    // Assert
                    Assert.IsTrue(bResult, "The Business is expected to be found.");
                }
            }
Пример #21
0
            public void VerifyNullShortNameIsNotUniqueWhenNull()
            {
                // Arrange    
                const string SHORT_NAME = null;

                // Act
                var isUnique = new EcomDataProvider().VerifyShortNameIsUnique(SHORT_NAME);

                // Assert
                Assert.IsFalse(isUnique, "The shortname expected not to be unique");
            }
Пример #22
0
            public void IsBusinessPresentReturnsFalse()
            {
                //Arrange
                const string REFERENCE_CODE = "0";

                // Act
                bool bResult = new EcomDataProvider().IsBusinessPresent(REFERENCE_CODE);

                // Assert
                Assert.IsFalse(bResult, "The Business is expected to be not found.");
            }
Пример #23
0
        public void GivenABusinessWithEagleAsSupplyPartnerIsInsertedIntoEcomWithShortnameFullnameBusinessAccountTypeId(string shortName, 
            string fullName, int businessAccountTypeId)
        {
            var ecomDataProvider = new EcomDataProvider();

            var businessAccount = EcomBusinessAccountFactory
                .Initialise()
                .WithShortName(shortName)
                .WithFullName(fullName)
                .WithBusinessAccountTypeId(businessAccountTypeId)
                .WithId(Guid.NewGuid())
                .WithModifiedDate(DateTime.Now.AddMinutes(-1))
                .Create();
            ecomDataProvider.InsertBusinessAccount(businessAccount);
            ecomDataProvider.InsertExernalProductProvider(businessAccount);
        }
Пример #24
0
            public void GetMostRecentBusinessUpdateTimeWhenNoBusinessesReturnsDefaultFromConfigFile()
            {
                //Arrange
                var ecommDataProvider = new EcomDataProvider();
                var defaultDate = ecommDataProvider.GetDefaultDate();

                // Act
                var modifiedTime = new EcomDataProvider().GetMostRecentBusinessUpdateTime();

                // Assert
                Assert.AreEqual(defaultDate, modifiedTime, "Result should be {0}", defaultDate);
            }
Пример #25
0
 private static EcomBusinessAccount GetEcomBusinessByShortname(string shortName)
 {
     IEnumerable<EcomBusinessAccount> eagleBusinessesInEcom = new EcomDataProvider().GetAllEcomBusinesses();
     return eagleBusinessesInEcom.SingleOrDefault(b => b.ShortName == shortName);
 }
Пример #26
0
            public void GetMostRecentBusinessUpdateTimeReturnsLastUpdate()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, 
                    DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    DateTime modifiedTime = new EcomDataProvider().GetMostRecentBusinessUpdateTime();

                    Assert.AreEqual(DateTime.Parse("2012-12-11 12:12:12.210"), modifiedTime);
                }
            }
Пример #27
0
            public void RunTaskExecutesSuccessfullyTwoConsecutiveTimes()
            {
                // Arrange
                IBusinessManager businessManager = new BusinessManager();
                DateTime fromDate = new DateTime(2012, 01, 1, 0, 0, 0, DateTimeKind.Utc);
                SyncBusinessesToEagle.FromDate = fromDate;
                SyncBusinessesToEagle.Identity = new GenericIdentity(WindowsServiceUserGuid.ToString());
                //UserHelper.SetupUser(WindowsUserName, UserHelper.VALIDUSERPASS, WindowsUserName, WindowsServiceUserGuid);
                SyncBusinessesToEagle.Run();
                
                fromDate = DateTime.UtcNow;
                DateTime expectedLastModifiedDateTime = businessManager.GetTimestampOfLastBusinessSyncedFromEcom();
                SyncBusinessesToEagle.FromDate = fromDate;
                SyncBusinessesToEagle.Identity = new GenericIdentity(WindowsServiceUserGuid.ToString());
                List<EcomBusinessAccount> expectedBusinessAccountList = new EcomDataProvider().GetLastModifiedBusinesses(fromDate, DateTime.UtcNow);

                // Act
                SyncBusinessesToEagle.Run();

                // Assert
                //verify if the latest timestamp in Eccom.BusinessAccount is the same as obtain before
                DateTime lastModifiedDateTime = businessManager.GetTimestampOfLastBusinessSyncedFromEcom();

                TimeSpan lastDateDiff = lastModifiedDateTime - expectedLastModifiedDateTime;
                Assert.IsTrue(lastDateDiff.TotalHours == 0, string.Format("The last modified date is not bigger than the one we had before running the task: lastModifiedDateTime - {0} ; expectedLastModifiedDateTime - {1}", lastModifiedDateTime, expectedLastModifiedDateTime));

                //verify that no business was changed in the meanwhile
                Assert.AreEqual(0, expectedBusinessAccountList.Count, "The list is expected to be null");
            }
Пример #28
0
            public void SaveBusinessAccountWhenNoExistingCreates()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    const string NON_EXISTING_SHORT_NAME = "noexists";

                    var businessaccount = new EcomBusinessAccount
                    {
                        Id = Guid.NewGuid(),
                        ModifiedDate = DateTime.Now,
                        FullName = "FullName",
                        CreatedByTitle = "Mr",
                        CreatedByFirstname = "CreatedByFirstname",
                        CreatedByLastname = "CreatedByLastname",
                        ModifiedByTitle = "ModifiedByTitle",
                        ModifiedByFirstname = "ModifiedByFirstname",
                        ModifiedByLastname = "ModifiedByLastname",
                        BusinessAccountStatusTypeId = 1,
                        BusinessAccountTypeId = 1,
                        ReferenceCode = "123",
                        ShortName = NON_EXISTING_SHORT_NAME,
                        IsMerchant = true,
                        VatNumber = "123-859-7425",
                        MerchantId = "12345",
                        MerchantPassword = "******",
                        MerchantPasswordExpiry = DateTime.Today,
                        AllowAmex = false,
                        AllowPaypal = true,
                        AllowThreeDSecure = true,
                        ContentId = NON_EXISTING_SHORT_NAME,
                        AddressLine1 = "Test Street 1",
                        City = "London",
                        PostCode = "N1 HT9",
                        Channels = new Collection<EcomChannel>
                                       {
                                           new EcomChannel
                                               {
                                                   ChannelName = "channel1"
                                               },
                                           new EcomChannel
                                               {
                                                   ChannelName = "channel2"
                                               },
                                           new EcomChannel
                                               {
                                                   ChannelName = "channel3"
                                               }
                                       }
                    };

                    var ecomDataProvider = new EcomDataProvider();
                    // Act
                    bool isBusinessInEcomBefore = ecomDataProvider.IsBusinessPresent(businessaccount.ReferenceCode);
                    Assert.IsFalse(isBusinessInEcomBefore, "business is already in database before save");

                    ecomDataProvider.SaveBusinessAccount(businessaccount);

                    // Assert
                    bool isBusinessInEcomAfter = ecomDataProvider.IsBusinessPresent(businessaccount.ShortName);

                    Assert.IsTrue(isBusinessInEcomAfter, "business hasn't been created");
                }
            }
Пример #29
0
            public void SaveBusinessAccountWhenExisitingUpdates()
            {
                using (new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA, DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    // Arrange
                    const string SHORT_NAME = "Bus2";

                    DateTime startUpdate = DateTime.UtcNow;

                    var businessaccount = new EcomBusinessAccount
                    {
                        Id = new Guid("1D99ACCA-8F44-44C9-A277-00BF03D7BA69"),
                        ModifiedDate = DateTime.Now,
                        FullName = "FullName",
                        CreatedByTitle = "Mr",
                        CreatedByFirstname = "CreatedByFirstname",
                        CreatedByLastname = "CreatedByLastname",
                        ModifiedByTitle = "ModifiedByTitle",
                        ModifiedByFirstname = "ModifiedByFirstname",
                        ModifiedByLastname = "ModifiedByLastname",
                        BusinessAccountStatusTypeId = 1,
                        BusinessAccountTypeId = 1,
                        ReferenceCode = "1000133",
                        ShortName = SHORT_NAME,
                        IsMerchant = true,
                        VatNumber = "123-859-7425",
                        MerchantId = "MERCH1627",
                        MerchantPassword = "******",
                        MerchantPasswordExpiry = DateTime.Today,
                        AllowAmex = false,
                        AllowPaypal = true,
                        AllowThreeDSecure = true,
                        ContentId = SHORT_NAME,
                        Channels = new Collection<EcomChannel>
                                       {
                                           new EcomChannel
                                               {
                                                   ChannelName = "toprooms"
                                               }
                                       }
                    };

                    // Act
                    bool isBusinessInEcomBefore = new EcomDataProvider().IsBusinessPresent(businessaccount.ShortName);
                    Assert.IsTrue(isBusinessInEcomBefore, "business should be already in database before save");

                    new EcomDataProvider().SaveBusinessAccount(businessaccount);

                    // Assert
                    DateTime updatedDateTime = new EcomDataProvider().GetMostRecentBusinessUpdateTime();

                    Assert.IsTrue(updatedDateTime.AddMinutes(1) >= startUpdate.AddMinutes(-1));
                }
            }
Пример #30
0
            public void VerifyContentIdIsNotUniqueForCreate()
            {
                using (
                    new TestDataHelper(TestQueryEcom.POPULATE_BUSINESSES, TestQueryEcom.CLEANUP_TEST_DATA,
                                       DbHelper.ECOM_CONNECTION_STRING_NAME))
                {
                    var ecomDataProvider = new EcomDataProvider();

                    // Arrange
                    // Use one of the existing content ids from the resx 1001
                    string contentId = "1001";

                    // Act
                    var isUnique = ecomDataProvider.VerifyContentIdIsUnique(null, contentId);

                    // Assert
                    Assert.IsFalse(isUnique, "The ContentId is not unique");
                }
            }