Exemplo n.º 1
0
        public async Task GetParentByGuidAsync_Should_Return_Parent()
        {
            ParentModel parent = await _repo.GetOnlyParentByNameAsync("crm");

            parent = await _repo.GetParentByIdAsync(parent.Id);

            parent.Should().NotBeNull();
            parent.Children.Should().NotBeNullOrEmpty();
        }
Exemplo n.º 2
0
        public void GetParentByGuid_Should_Return_Parent()
        {
            ParentModel parent = _repo.GetOnlyParentByName("crm");

            parent = _repo.GetParentById(parent.Id);

            parent.Should().NotBeNull();
            parent.Children.Should().NotBeNullOrEmpty();
        }
Exemplo n.º 3
0
        public async Task Basic_Transaction_Management_Async()
        {
            ParentModel initial = null;
            ParentModel intrans = null;
            ParentModel outside = null;
            int         id;

            TestHarnessRepository repo2 = new TestHarnessRepository(_provider);
            TestHarnessRepository repo3 = new TestHarnessRepository(_provider);

            IAsyncUnitOfWork uow = await _repo.CreateAsyncUnitOfWork(new[] { _repo, repo2, repo3 });

            using (uow)
            {
                try
                {
                    initial = await _repo.GetOnlyParentByNameAsync("crm");

                    id = initial.Id;

                    initial = await _repo.GetParentByIdAsync(id);

                    await repo2.InsertChildAsync(new ClientRedirectUri
                    {
                        ClientId = id,
                        Uri      = "asdfasdf"
                    });

                    await repo3.InsertChildAsync(new ClientRedirectUri
                    {
                        ClientId = id,
                        Uri      = "fdsafdsa"
                    });

                    intrans = await _repo.GetParentByIdAsync(id);

                    await _repo.DbOperationAsync("crm");
                }
                finally
                {
                    uow.RollbackTransaction();
                }
            }

            outside = await _repo.GetParentByIdAsync(id);

            initial.Should().NotBeNull();
            intrans.Should().NotBeNull();
            outside.Should().NotBeNull();
            initial.Children.Should().NotBeNullOrEmpty();
            intrans.Children.Should().NotBeNullOrEmpty();
            outside.Children.Should().NotBeNullOrEmpty();
            initial.Children.Count().Should().Be(intrans.Children.Count() - 2);
            initial.Children.Count().Should().Be(outside.Children.Count());
        }
Exemplo n.º 4
0
        public async Task Get_Should_Load_Object_By_Identity_Async()
        {
            ParentModel parent = await _repo.GetOnlyParentByNameAsync("crm");

            parent = _repo.GetParentById(parent.Id);
            ClientRedirectUri uri = await _repo.GetAsync <ClientRedirectUri>(parent.Children.First().ClientRedirectUriId);

            parent.Should().NotBeNull();
            parent.Children.Should().NotBeNullOrEmpty();
            uri.Should().NotBeNull();
        }
Exemplo n.º 5
0
        public void Get_Should_Load_Object_By_Identity()
        {
            ParentModel parent = _repo.GetOnlyParentByName("crm");

            parent = _repo.GetParentById(parent.Id);
            ClientRedirectUri uri = _repo.Get <ClientRedirectUri>(parent.Children.First().ClientRedirectUriId);

            parent.Should().NotBeNull();
            parent.Children.Should().NotBeNullOrEmpty();
            uri.Should().NotBeNull();
        }
Exemplo n.º 6
0
        public void Basic_Transaction_Management()
        {
            ParentModel initial = null;
            ParentModel intrans = null;

            TestHarnessRepository repo2 = new TestHarnessRepository(_provider);
            TestHarnessRepository repo3 = new TestHarnessRepository(_provider);

            IUnitOfWork uow = _repo.CreateUnitOfWork(new[] { _repo, repo2, repo3 });

            using (uow)
            {
                try
                {
                    initial = _repo.GetOnlyParentByName("crm");
                    initial = _repo.GetParentById(initial.Id);
                    repo2.InsertChild(new ClientRedirectUri
                    {
                        ClientId = initial.Id,
                        Uri      = "asdfasdf"
                    });
                    repo3.InsertChild(new ClientRedirectUri
                    {
                        ClientId = initial.Id,
                        Uri      = "fdsafdsa"
                    });
                    intrans = _repo.GetParentById(initial.Id);
                }
                finally
                {
                    uow.RollbackTransaction();
                }
            }

            initial.Should().NotBeNull();
            intrans.Should().NotBeNull();
            initial.Children.Should().NotBeNullOrEmpty();
            intrans.Children.Should().NotBeNullOrEmpty();
            initial.Children.Count().Should().Be(intrans.Children.Count() - 2);
        }