Ejemplo n.º 1
0
        public void CreateAlreadyExistingItemResultsInException()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping         =
                new RedirectMapping
            {
                Guid         = Guid.NewGuid(),
                Uri          = new Uri("http://www.silkveil.net"),
                RedirectType = RedirectType.Permanent
            };

            redirectMappingProvider.Create(redirectMapping);

            Assert.That(() => redirectMappingProvider.Create(redirectMapping), Throws.Exception.TypeOf(typeof(DuplicateMappingException)));
        }
        public void CreateAlreadyExistingItemResultsInException()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping =
                new RedirectMapping
                {
                    Guid = Guid.NewGuid(),
                    Uri = new Uri("http://www.silkveil.net"),
                    RedirectType = RedirectType.Permanent
                };

            redirectMappingProvider.Create(redirectMapping);

            Assert.That(() => redirectMappingProvider.Create(redirectMapping), Throws.Exception.TypeOf(typeof(DuplicateMappingException)));
        }
Ejemplo n.º 3
0
        public void ReadAllReturnsNonEmptyCollectionAfterCreate()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping         =
                new RedirectMapping
            {
                Guid         = Guid.NewGuid(),
                Uri          = new Uri("http://www.silkveil.net"),
                RedirectType = RedirectType.Permanent
            };

            int count = 0;

            redirectMappingProvider.MappingsAvailable += r =>
            {
                Assert.That(r, Is.InstanceOf(typeof(IEnumerable <IRedirectMapping>)));
                Assert.That(r.Count(), Is.EqualTo(1));

                Assert.That(r.First().Guid, Is.EqualTo(redirectMapping.Guid));
                Assert.That(r.First().Uri, Is.EqualTo(redirectMapping.Uri));
                Assert.That(r.First().RedirectType, Is.EqualTo(redirectMapping.RedirectType));

                count++;
            };

            redirectMappingProvider.Create(redirectMapping);
            redirectMappingProvider.ReadAll();

            Assert.That(count, Is.EqualTo(1));
        }
Ejemplo n.º 4
0
        public void Update()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping         =
                new RedirectMapping
            {
                Guid         = Guid.NewGuid(),
                Uri          = new Uri("http://www.google.de"),
                RedirectType = RedirectType.Temporary
            };

            int count = 0;

            redirectMappingProvider.MappingAvailable += r =>
            {
                Assert.That(r.Uri, Is.EqualTo(redirectMapping.Uri));
                Assert.That(r.RedirectType, Is.EqualTo(redirectMapping.RedirectType));
                count++;
            };

            redirectMappingProvider.Create(redirectMapping);

            redirectMapping.Uri          = new Uri("http://www.silkveil.net");
            redirectMapping.RedirectType = RedirectType.Permanent;
            redirectMappingProvider.Update(redirectMapping);
            redirectMappingProvider.ReadById(redirectMapping.Guid);

            Assert.That(count, Is.EqualTo(1));
        }
Ejemplo n.º 5
0
        public void DeleteByGuid()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping         =
                new RedirectMapping
            {
                Guid         = Guid.NewGuid(),
                Uri          = new Uri("http://www.silkveil.net"),
                RedirectType = RedirectType.Permanent
            };

            int count = 0;

            redirectMappingProvider.MappingsAvailable += r =>
            {
                Assert.That(r.Count(), Is.EqualTo(0));
                count++;
            };

            redirectMappingProvider.Create(redirectMapping);
            redirectMappingProvider.Delete(redirectMapping.Guid);
            redirectMappingProvider.ReadAll();

            Assert.That(count, Is.EqualTo(1));
        }
        public void DeleteByGuid()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping =
                new RedirectMapping
                {
                    Guid = Guid.NewGuid(),
                    Uri = new Uri("http://www.silkveil.net"),
                    RedirectType = RedirectType.Permanent
                };

            int count = 0;
            redirectMappingProvider.MappingsAvailable += r =>
            {
                Assert.That(r.Count(), Is.EqualTo(0));
                count++;
            };

            redirectMappingProvider.Create(redirectMapping);
            redirectMappingProvider.Delete(redirectMapping.Guid);
            redirectMappingProvider.ReadAll();

            Assert.That(count, Is.EqualTo(1));
        }
        public void Update()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping =
                new RedirectMapping
                {
                    Guid = Guid.NewGuid(),
                    Uri = new Uri("http://www.google.de"),
                    RedirectType = RedirectType.Temporary
                };

            int count = 0;
            redirectMappingProvider.MappingAvailable += r =>
            {
                Assert.That(r.Uri, Is.EqualTo(redirectMapping.Uri));
                Assert.That(r.RedirectType, Is.EqualTo(redirectMapping.RedirectType));
                count++;
            };

            redirectMappingProvider.Create(redirectMapping);

            redirectMapping.Uri = new Uri("http://www.silkveil.net");
            redirectMapping.RedirectType = RedirectType.Permanent;
            redirectMappingProvider.Update(redirectMapping);
            redirectMappingProvider.ReadById(redirectMapping.Guid);

            Assert.That(count, Is.EqualTo(1));
        }
        public void ReadAllReturnsNonEmptyCollectionAfterCreate()
        {
            var redirectMappingProvider = new RedirectMappingProvider(this._container);
            var redirectMapping =
                new RedirectMapping
                    {
                        Guid = Guid.NewGuid(),
                        Uri = new Uri("http://www.silkveil.net"),
                        RedirectType = RedirectType.Permanent
                    };

            int count = 0;
            redirectMappingProvider.MappingsAvailable += r =>
            {
                Assert.That(r, Is.InstanceOf(typeof(IEnumerable<IRedirectMapping>)));
                Assert.That(r.Count(), Is.EqualTo(1));

                Assert.That(r.First().Guid, Is.EqualTo(redirectMapping.Guid));
                Assert.That(r.First().Uri, Is.EqualTo(redirectMapping.Uri));
                Assert.That(r.First().RedirectType, Is.EqualTo(redirectMapping.RedirectType));

                count++;
            };

            redirectMappingProvider.Create(redirectMapping);
            redirectMappingProvider.ReadAll();

            Assert.That(count, Is.EqualTo(1));
        }