Ejemplo n.º 1
0
        public static async Task Assert(this ProjectionTestSpecification <IAsyncDocumentSession> specification)
        {
            if (specification == null)
            {
                throw new ArgumentNullException("specification");
            }
            using (var store = new EmbeddableDocumentStore
            {
                RunInMemory = true,
                DataDirectory = Path.GetTempPath()
            })
            {
                store.Configuration.Storage.Voron.AllowOn32Bits = true;
                store.Initialize();
                using (var session = store.OpenAsyncSession())
                {
                    await new Projector <IAsyncDocumentSession>(specification.Resolver).
                    ProjectAsync(session, specification.Messages);
                    await session.SaveChangesAsync();

                    var result = await specification.Verification(session, CancellationToken.None);

                    if (result.Failed)
                    {
                        throw new AssertionException(result.Message);
                    }
                }
            }
        }
        public void MessagesReturnsExpectedResult()
        {
            var messages = new [] { new object(), new object() };
            var sut      = new ProjectionTestSpecification <object>(
                Resolve.WhenEqualToHandlerMessageType(new ProjectionHandler <object> [0]),
                messages,
                (session, token) => Task.FromResult(VerificationResult.Pass()));

            var result = sut.Messages;

            Assert.That(result, Is.SameAs(messages));
        }
        public void ResolverReturnsExpectedResult()
        {
            var resolver = Resolve.WhenEqualToHandlerMessageType(new ProjectionHandler <object> [0]);
            var sut      = new ProjectionTestSpecification <object>(
                resolver,
                new object[0],
                (session, token) => Task.FromResult(VerificationResult.Pass()));

            var result = sut.Resolver;

            Assert.That(result, Is.SameAs(resolver));
        }
        public void VerificationReturnsExpectedResult()
        {
            Func <object, CancellationToken, Task <VerificationResult> > verification =
                (session, token) => Task.FromResult(VerificationResult.Pass());
            var sut = new ProjectionTestSpecification <object>(
                Resolve.WhenEqualToHandlerMessageType(new ProjectionHandler <object> [0]),
                new object[0],
                verification);

            var result = sut.Verification;

            Assert.That(result, Is.SameAs(verification));
        }
Ejemplo n.º 5
0
        public static async Task Assert(this ProjectionTestSpecification <MemoryCache> specification)
        {
            if (specification == null)
            {
                throw new ArgumentNullException("specification");
            }
            using (var cache = new MemoryCache(new Random().Next().ToString()))
            {
                await new Projector <MemoryCache>(specification.Resolver).
                ProjectAsync(cache, specification.Messages);
                var result = await specification.Verification(cache, CancellationToken.None);

                if (result.Failed)
                {
                    throw new AssertionException(result.Message);
                }
            }
        }