Ejemplo n.º 1
0
        public void GenericTools_RepositoryHandler_AddUpdateDelete()
        {
            //register sample service
            RepositoryHandler.Add(new SampleModelRepository());

            var item = RepositoryHandler.Get <SampleModelRepository>().Add(new SampleModel()
            {
                Age = 50
            });

            MakeSure.That(item.Age).Is(50);
            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Get(i => i == item)).Is(item);
            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(4);

            var newItem = RepositoryHandler.Get <SampleModelRepository>().Update(item, new SampleModel()
            {
                Age = 53
            });

            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Get(i => i == newItem)).Is(newItem);
            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(4);

            RepositoryHandler.Get <SampleModelRepository>().Delete(i => i.Age > 40);
            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(3);

            MakeSure.That(() => RepositoryHandler.Get <SampleModelRepository>().SaveChanges()).DoesNotThrow();
        }
Ejemplo n.º 2
0
        public void GenericTools_RepositoryHandler_GetAll()
        {
            //register sample service
            RepositoryHandler.Add(new SampleModelRepository());

            var count = RepositoryHandler.Get <SampleModelRepository>().GetAll().Count();

            MakeSure.That(count).Is(3);

            var count2 = RepositoryHandler.Get <SampleModelRepository>().GetAll(i => i.Age > 17).Count();

            MakeSure.That(count2).Is(2);
        }
Ejemplo n.º 3
0
        public void GenericTools_RepositoryHandler_Get()
        {
            //register sample service
            RepositoryHandler.Add(new SampleModelRepository());

            var sampleModel = RepositoryHandler.Get <SampleModelRepository>().Get();

            MakeSure.That(sampleModel).IsNot(null);
            MakeSure.That(sampleModel.Age).Is(1);

            var sampleModel2 = RepositoryHandler.Get <SampleModelRepository>().Get(i => i.Age > 17);

            MakeSure.That(sampleModel2.Age).Is(22);

            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(3);
        }
Ejemplo n.º 4
0
        public void GenericTools_RepositoryHandler_RegisterMultiple()
        {
            MakeSure.That(() =>
            {
                var items = RepositoryHandler.Add(
                    new SampleModelRepository(),
                    new SampleModelRepository(),
                    new SampleModelRepository()
                    );

                MakeSure.That(items.Count()).Is(3);
            }).DoesNotThrow();


            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>()).IsNot(null);
        }
Ejemplo n.º 5
0
        public void GenericTools_RepositoryHandler()
        {
            var vm = RepositoryHandler.Add(new SampleModelRepository());

            MakeSure.That(RepositoryHandler.Get <SampleModelRepository>()).Is((SampleModelRepository)vm);
        }