Ejemplo n.º 1
0
        public void SaveAndLoadSampleDataForClassToXmlTest()
        {
            SamplerServices <PocoEvents> .SaveToFile(SamplerServices <PocoEvents> .CreateSampleData(20));

            Assert.IsTrue(SamplerServices <PocoEvents> .LoadSavedFile().Any());
            SamplerServices <PocoEvents> .DeleteFile();
        }
Ejemplo n.º 2
0
        public void TestCreatingUniqueGuid()
        {
            SamplerOptions samplerOptions = new SamplerOptions();

            samplerOptions.PropertyOptions.Add("UserId", SamplerOptions.Options.IsUnique);
            var result = SamplerServices <Poco3> .CreateSampleData(10, samplerOptions);

            Assert.IsTrue(result.Count == 10);
        }
Ejemplo n.º 3
0
        public void GetSampleWithNullOptionsTest()
        {
            SamplerOptions options = new SamplerOptions();

            options.PropertyOptions.Add("LongText", SamplerOptions.Options.NullValue);
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(10, options);

            Assert.IsTrue(eventsList.Count == 10);

            foreach (var pocoEventse in eventsList)
            {
                Assert.IsTrue(pocoEventse.LongText == null);
            }
        }
Ejemplo n.º 4
0
        public void InitializeTest()
        {
            GenericIdentity identity = new GenericIdentity("jsucupira");

            string[]         roles     = { SecurityGroups.ADMINISTRATOR };
            GenericPrincipal principal = new GenericPrincipal(identity, roles);

            Thread.CurrentPrincipal = principal;

            MefLoader.Initialize();
            IStoreRepository repository = MefBase.Resolve <IStoreRepository>();

            StoreSelector = MefBase.Resolve <IStoreSelector>();
            StoreUpdator  = MefBase.Resolve <IStoreUpdator>();

            SamplerOptions samplerOptions = new SamplerOptions();

            samplerOptions.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyValue = "*****@*****.**",
                PropertyName  = nameof(Store.ManagerEmail)
            }, SamplerOptions.Options.DefaultValue);
            samplerOptions.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyValue = "http://www.test.com/",
                PropertyName  = nameof(Store.WebSiteUrl)
            }, SamplerOptions.Options.DefaultValue);

            samplerOptions.PropertyOptions.Add(nameof(Store.Description), SamplerOptions.Options.Paragraph);
            samplerOptions.PropertyOptions.Add(nameof(Store.Name), SamplerOptions.Options.OneWord);
            samplerOptions.PropertyOptions.Add(nameof(Store.ManagerName), SamplerOptions.Options.OneWord);
            List <Store> stores = SamplerServices <Store> .CreateSampleData(ACTIVE_STORES - 1, samplerOptions);

            stores.ForEach(t => t.Activate());
            //Creating active classes
            stores.ForEach(t => repository.Create(t));

            //Creating non active classes
            SamplerServices <Store> .CreateSampleData(NON_ACTIVE_STORES, samplerOptions).ForEach(t => repository.Create(t));

            samplerOptions.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyName  = nameof(Store.Id),
                PropertyValue = DefaultStoreId.ToString()
            }, SamplerOptions.Options.DefaultValue);
            List <Store> defaultStore = SamplerServices <Store> .CreateSampleData(1, samplerOptions);

            defaultStore.ForEach(t => t.Activate());
            defaultStore.ForEach(t => repository.Create(t));
        }
Ejemplo n.º 5
0
        public void AttachItemsToListTest()
        {
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(10);

            foreach (var events in eventsList)
            {
                events.Pocos = SamplerServices <Poco> .CreateSampleData(10);
            }

            SamplerServices <PocoEvents> .SaveToFile(eventsList);

            SamplerServices <PocoEvents> .DeleteFile();

            Assert.IsTrue(eventsList.Count == 10);
        }
Ejemplo n.º 6
0
        public void GetSampleWithOptionsEnumDefaultValueTest()
        {
            SamplerOptions options = new SamplerOptions();

            options.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyName = "EventStatus", PropertyValue = "6"
            }, SamplerOptions.Options.DefaultValue);
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(10, options);

            foreach (var pocoEventse in eventsList.OrderBy(c => c.EventId))
            {
                Assert.IsTrue(pocoEventse.EventStatus == EventTypes.Deleted);
            }
        }
Ejemplo n.º 7
0
        public void CreateTest_NotValidUrl()
        {
            SamplerOptions samplerOptions = new SamplerOptions();

            samplerOptions.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyValue = "www.asdf",
                PropertyName  = nameof(Store.WebSiteUrl)
            }, SamplerOptions.Options.DefaultValue);

            samplerOptions.PropertyOptions.Add(nameof(Store.ManagerEmail), SamplerOptions.Options.NullValue);
            List <Store> stores = SamplerServices <Store> .CreateSampleData(1, samplerOptions);

            stores.ForEach(t => t.Activate());
            stores.ForEach(t => StoreUpdator.Create(t));
        }
Ejemplo n.º 8
0
        public void GetSampleWithOptionsDefaultValueAndSequenceTest()
        {
            SamplerOptions options = new SamplerOptions();

            options.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyName = "UnitId", PropertyValue = "1"
            }, SamplerOptions.Options.DefaultValue);
            options.PropertyOptions.Add("UnitId", SamplerOptions.Options.Sequential);
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(10, options);

            int currentUnit = 1;

            foreach (var pocoEventse in eventsList.OrderBy(c => c.UnitId))
            {
                Assert.IsTrue(pocoEventse.UnitId == currentUnit);
                currentUnit++;
            }
        }
Ejemplo n.º 9
0
        public void GetSampleWithOptionsDateTimeSequencialTest()
        {
            SamplerOptions options = new SamplerOptions();

            options.PropertyOptions.Add("CreatedDt", SamplerOptions.Options.Sequential);
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(10, options);

            PocoEvents firstItem  = eventsList.OrderBy(c => c.CreatedDt).FirstOrDefault();
            DateTime   firstValue = DateTime.Now;

            if (firstItem != null)
            {
                firstValue = firstItem.CreatedDt;
            }

            foreach (var pocoEventse in eventsList.OrderBy(c => c.CreatedDt))
            {
                Assert.IsTrue(pocoEventse.CreatedDt == firstValue);
                firstValue = firstValue.AddDays(1);
            }
        }
Ejemplo n.º 10
0
        public void GetSampleWithOptionsSequencialTest()
        {
            SamplerOptions options = new SamplerOptions();

            options.PropertyOptions.Add("EventId", SamplerOptions.Options.Sequential);
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(10, options);

            PocoEvents firstItem  = eventsList.OrderBy(c => c.EventId).FirstOrDefault();
            int        firstValue = 0;

            if (firstItem != null)
            {
                firstValue = firstItem.EventId;
            }

            foreach (var pocoEventse in eventsList.OrderBy(c => c.EventId))
            {
                Assert.IsTrue(pocoEventse.EventId == firstValue);
                firstValue++;
            }
        }
Ejemplo n.º 11
0
        public void CreateTest()
        {
            SamplerOptions samplerOptions = new SamplerOptions();

            samplerOptions.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyValue = "http://www.test.com/",
                PropertyName  = nameof(Store.WebSiteUrl)
            }, SamplerOptions.Options.DefaultValue);

            samplerOptions.PropertyDefaults.Add(new PropertiesSettings
            {
                PropertyValue = "*****@*****.**",
                PropertyName  = nameof(Store.ManagerEmail)
            }, SamplerOptions.Options.DefaultValue);


            List <Store> stores = SamplerServices <Store> .CreateSampleData(1, samplerOptions);

            stores.ForEach(t => t.Activate());
            stores.ForEach(t => StoreUpdator.Create(t));
        }
Ejemplo n.º 12
0
        private static void LicenseTest()
        {
            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(
                new Dictionary <string, string> {
                { "SampleDataLocation", @"c:\Temp\" }
            }
                ).Build();

            var samplerServices = new SamplerServices <LicenseModel>(configuration);

            var options = new SamplerOptions();

            var licenseModels = SamplerServices <LicenseModel> .CreateSampleData(1, options);

            foreach (var licenseModel in licenseModels)
            {
                licenseModel.AdditionalContact = SamplerServices <ContactModel> .CreateSampleData(2);
            }

            samplerServices.SaveToFile(licenseModels);
        }
Ejemplo n.º 13
0
        public void GetSampleWithOptionsTest()
        {
            var idList = new List <int>();
            var dates  = new List <DateTime>();

            SamplerOptions options = new SamplerOptions();

            options.PropertyOptions.Add("Id", SamplerOptions.Options.IsUnique);
            options.PropertyOptions.Add("LongText", SamplerOptions.Options.Paragraph);
            options.PropertyOptions.Add("CreatedDt", SamplerOptions.Options.IsUnique);
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(100, options);

            foreach (var pocoEventse in eventsList)
            {
                idList.Add(pocoEventse.Id);
                dates.Add(pocoEventse.CreatedDt);

                Assert.IsTrue(pocoEventse.LongText.Length > 20);
            }

            Assert.IsFalse(idList.HasDuplicates());
            Assert.IsFalse(dates.HasDuplicates());
        }
Ejemplo n.º 14
0
        public void CreateWithPrivateConstructor()
        {
            List <PocoPrivate> eventsList = SamplerServices <PocoPrivate> .CreateSampleData(10);

            Assert.IsTrue(eventsList.Count == 10);
        }
Ejemplo n.º 15
0
        public void CreateSampleDataForClassTest()
        {
            List <PocoEvents> eventsList = SamplerServices <PocoEvents> .CreateSampleData(10);

            Assert.IsTrue(eventsList.Count == 10);
        }
Ejemplo n.º 16
0
        private static void CheckoutTest()
        {
            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(
                new Dictionary <string, string> {
                { "SampleDataLocation", @"c:\Temp\" }
            }
                ).Build();

            var samplerServices = new SamplerServices <CheckoutVM>(configuration);

            var visitSettings = new PropertiesSettings
            {
                PropertyName  = nameof(CheckoutVM.VisitDate),
                PropertyValue = DateTimeOffset.UtcNow.AddDays(-1).ToString()
            };

            var location = new PropertiesSettings
            {
                PropertyName  = nameof(CheckoutVM.LocationId),
                PropertyValue = "1"
            };

            var TestId = new PropertiesSettings
            {
                PropertyName  = nameof(CheckoutVM.TestId),
                PropertyValue = "1"
            };

            var city = new PropertiesSettings
            {
                PropertyName  = nameof(CheckoutVM.City),
                PropertyValue = "Tampa"
            };

            var state = new PropertiesSettings
            {
                PropertyName  = nameof(CheckoutVM.State),
                PropertyValue = "FL"
            };

            var options = new SamplerOptions();

            options.PropertyOptions.Add(nameof(CheckoutVM.FirstName), SamplerOptions.Options.OneWord);
            options.PropertyOptions.Add(nameof(CheckoutVM.LastName), SamplerOptions.Options.OneWord);
            options.PropertyOptions.Add(nameof(CheckoutVM.EMail), SamplerOptions.Options.Email);
            options.PropertyOptions.Add(nameof(CheckoutVM.PhoneNumber), SamplerOptions.Options.Phone);
            options.PropertyOptions.Add(nameof(CheckoutVM.Address), SamplerOptions.Options.Phrase);

            options.PropertyDefaults.Add(visitSettings, SamplerOptions.Options.DefaultValue);
            options.PropertyDefaults.Add(location, SamplerOptions.Options.DefaultValue);
            options.PropertyDefaults.Add(TestId, SamplerOptions.Options.DefaultValue);
            options.PropertyDefaults.Add(city, SamplerOptions.Options.DefaultValue);
            options.PropertyDefaults.Add(state, SamplerOptions.Options.DefaultValue);

            var checkouts = SamplerServices <CheckoutVM> .CreateSampleData(20, options);

            visitSettings.PropertyValue = DateTimeOffset.UtcNow.ToString();
            checkouts.AddRange(SamplerServices <CheckoutVM> .CreateSampleData(25, options));
            visitSettings.PropertyValue = DateTimeOffset.UtcNow.AddDays(1).ToString();
            checkouts.AddRange(SamplerServices <CheckoutVM> .CreateSampleData(30, options));

            var random = new Random(1);

            foreach (var item in checkouts)
            {
                item.Sex         = random.Next(2) % 2 == 0 ? "Male" : "Female";
                item.DateOfBirth = item.DateOfBirth.AddYears(-random.Next(50));
                item.VisitDate   = item.VisitDate.AddHours(random.Next(48));
                item.VisitDate   = item.VisitDate.AddMinutes(random.Next(400));
            }

            samplerServices.SaveToFile(checkouts);
        }