コード例 #1
0
        public void ObjectsShouldBeRoundtrippable()
        {
            new TestScheduler().With(sched =>
            {
                string path;
                var input = new UserObject()
                {
                    Bio = "A totally cool cat!", Name = "octocat", Blog = "http://www.github.com"
                };
                UserObject result;

                using (Utility.WithEmptyDirectory(out path))
                {
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        fixture.InsertObject("key", input);
                    }
                    sched.Start();
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        var action = fixture.GetObjectAsync <UserObject>("key");
                        sched.Start();
                        result = action.First();
                    }
                }

                Assert.Equal(input.Blog, result.Blog);
                Assert.Equal(input.Bio, result.Bio);
                Assert.Equal(input.Name, result.Name);
            });
        }
コード例 #2
0
        public void ObjectsShouldBeRoundtrippable()
        {
            new TestScheduler().With(sched =>
            {
                string path;
                var input = new UserObject() {Bio = "A totally cool cat!", Name = "octocat", Blog = "http://www.github.com"};
                UserObject result;

                using (Utility.WithEmptyDirectory(out path))
                {
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        fixture.InsertObject("key", input);
                    }
                    sched.Start();
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        var action = fixture.GetObjectAsync<UserObject>("key");
                        sched.Start();
                        result = action.First();
                    }
                }

                Assert.Equal(input.Blog, result.Blog);
                Assert.Equal(input.Bio, result.Bio);
                Assert.Equal(input.Name, result.Name);
            });
        }
コード例 #3
0
        public void ArraysShouldBeRoundtrippableUsingObjectFactory()
        {
            new TestScheduler().With(sched =>
            {
                string path;
                var input = new[] {new UserModel(new UserObject()) {Age = 123, Name = "Old"}, new UserModel(new UserObject()) {Age = 123, Name = "Old"}};
                UserModel[] result;

                using (Utility.WithEmptyDirectory(out path))
                {
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        fixture.InsertObject("key", input);
                    }
                    sched.Start();
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        var action = fixture.GetObjectAsync<UserModel[]>("key");
                        sched.Start();
                        result = action.First();
                    }
                }

                Assert.Equal(input.First().Age, result.First().Age);
                Assert.Equal(input.First().Name, result.First().Name);
                Assert.Equal(input.Last().Age, result.Last().Age);
                Assert.Equal(input.Last().Name, result.Last().Name);
            });
        }
コード例 #4
0
        public void ArraysShouldBeRoundtrippableUsingObjectFactory()
        {
            new TestScheduler().With(sched =>
            {
                string path;
                var input = new[] { new UserModel(new UserObject())
                                    {
                                        Age = 123, Name = "Old"
                                    }, new UserModel(new UserObject())
                                    {
                                        Age = 123, Name = "Old"
                                    } };
                UserModel[] result;

                using (Utility.WithEmptyDirectory(out path))
                {
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        fixture.InsertObject("key", input);
                    }
                    sched.Start();
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        var action = fixture.GetObjectAsync <UserModel[]>("key");
                        sched.Start();
                        result = action.First();
                    }
                }

                Assert.Equal(input.First().Age, result.First().Age);
                Assert.Equal(input.First().Name, result.First().Name);
                Assert.Equal(input.Last().Age, result.Last().Age);
                Assert.Equal(input.Last().Name, result.Last().Name);
            });
        }
コード例 #5
0
        public void ObjectsCanBeCreatedUsingObjectFactory()
        {
            new TestScheduler().With(sched =>
            {
                string path;
                var input = new UserModel(new UserObject())
                {
                    Age = 123, Name = "Old"
                };
                UserModel result;

                using (Utility.WithEmptyDirectory(out path))
                {
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        fixture.InsertObject("key", input);
                    }
                    sched.Start();
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        var action = fixture.GetObjectAsync <UserModel>("key");
                        sched.Start();
                        result = action.First();
                    }
                }

                Assert.Equal(input.Age, result.Age);
                Assert.Equal(input.Name, result.Name);
            });
        }
コード例 #6
0
        public void ObjectsCanBeCreatedUsingObjectFactory()
        {
            new TestScheduler().With(sched =>
            {
                string path;
                var input = new UserModel(new UserObject()) {Age = 123, Name = "Old"};
                UserModel result;

                using (Utility.WithEmptyDirectory(out path))
                {
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        fixture.InsertObject("key", input);
                    }
                    sched.Start();
                    using (var fixture = new TPersistentBlobCache(path))
                    {
                        var action = fixture.GetObjectAsync<UserModel>("key");
                        sched.Start();
                        result = action.First();
                    }
                }

                Assert.Equal(input.Age, result.Age);
                Assert.Equal(input.Name, result.Name);
            });
        }