Exemplo n.º 1
0
        public void GivenKeyAsString_WhenTypedGetItemIsCalled_ThenCorrectItemCanBeConvertedToCorectType()
        {
            //Assign
            const long id = 1L;

            const string propityValue = "NotDefaultValue";
            var          fi           = new FurnaceItemInformation <long> {
                Id = id, ContentTypeFullName = ContentType.FullName
            };
            var returnJson = new Stub
            {
                FurnaceItemInformation = fi,
                Test = propityValue
            }.BuildSerialisedString();

            var key = RedisBackedFurnaceItems.CreateItemKey(id, ContentType);

            Client.Hashes[key][SiteConfiguration.DefaultSiteCulture.Name].Returns(returnJson);

            ContentTypes.GetContentTypes().Returns(new[] { ContentType });

            //Act
            var result = Sut.GetItem(key).As <Stub>();

            //Assert
            Assert.That(result, Is.TypeOf <Stub>());
            Assert.That(result.Test, Is.EqualTo(propityValue));
        }
Exemplo n.º 2
0
        public void WhenGetItemIsCalled_ThenTheReturnedItem_IsCorrect()
        {
            //Assign
            const long id = 1L;

            ContentType.AddPropity("Test", "string");
            var item = Sut.CreateItem(ContentType);

            item.Id = id;

            const string propityValue = "NotDefaultValue";
            var          fi           = new FurnaceItemInformation <long>()
            {
                Id = id
            };
            var returnJson = new Stub
            {
                FurnaceItemInformation = fi,
                Test = propityValue
            }.BuildSerialisedString();

            var key = RedisBackedFurnaceItems.CreateItemKey(id, ContentType);

            Client.Hashes[key][SiteConfiguration.DefaultSiteCulture.Name].Returns(returnJson);

            //Act
            var result = Sut.GetItem(id, ContentType);

            //Assert
            Assert.That(result.Id, Is.EqualTo(id));
            Assert.That(result["Test"], Is.EqualTo(propityValue));
            Assert.That(result.ContentType.Name == ContentTypeName);
        }
Exemplo n.º 3
0
        public void GivenKeyAsString_WhenTypedGetItemIsCalled_ThenCorrectItemReturned()
        {
            //Assign
            const long id = 1L;

            const string propityValue = "NotDefaultValue";
            var fi = new FurnaceItemInformation<long> {Id = id, ContentTypeFullName = ContentType.FullName};
            var returnJson = new Stub
            {
                FurnaceItemInformation = fi,
                Test = propityValue
            }.BuildSerialisedString();

            var key = RedisBackedFurnaceItems.CreateItemKey(id, ContentType);

            Client.Hashes[key][SiteConfiguration.DefaultSiteCulture.Name].Returns(returnJson);

            ContentTypes.GetContentTypes().Returns(new[] {ContentType});

            //Act
            var result = Sut.GetItem(key);

            //Assert
            Assert.That(result.Id, Is.EqualTo(id));
            Assert.That(result["Test"], Is.EqualTo(propityValue));
            Assert.That(result.ContentType.Name, Is.EqualTo(ContentTypeName));
        }
Exemplo n.º 4
0
 public void GivenJapaneseAsTheCultureSetUp()
 {
     CultureInfo = CultureInfo.GetCultureInfo("ja-JP");
     var fi = new FurnaceItemInformation<long>();
     CultureStub = new Stub
     {
         FurnaceItemInformation = fi,
         Test = "bonjour"
     };
 }
Exemplo n.º 5
0
            public void GivenJapaneseAsTheCultureSetUp()
            {
                CultureInfo = CultureInfo.GetCultureInfo("ja-JP");
                var fi = new FurnaceItemInformation <long>();

                CultureStub = new Stub
                {
                    FurnaceItemInformation = fi,
                    Test = "bonjour"
                };
            }
Exemplo n.º 6
0
            public void GivenJapaneseAsTheCultureSetUp()
            {
                CultureInfo = CultureInfo.GetCultureInfo("fr-FR");
                var fi = new FurnaceItemInformation <long>();

                CultureStub = new Stub
                {
                    FurnaceItemInformation = fi,
                    Test = "こんにいちわ"
                };
            }
Exemplo n.º 7
0
        public void LocalisationTestsSetUp()
        {
            Id = 99L;
            Key = RedisBackedFurnaceItems.CreateItemKey(Id, typeof(Stub));
            var fi = new FurnaceItemInformation<long>();
            DefultCultureStub = new Stub
            {

                Test = "Hello"
            };
            Client.Hashes[Key][SiteConfiguration.DefaultSiteCulture.Name].Returns(DefultCultureStub.BuildSerialisedString());
        }
Exemplo n.º 8
0
        public void LocalisationTestsSetUp()
        {
            Id  = 99L;
            Key = RedisBackedFurnaceItems.CreateItemKey(Id, typeof(Stub));
            var fi = new FurnaceItemInformation <long>();

            DefultCultureStub = new Stub
            {
                Test = "Hello"
            };
            Client.Hashes[Key][SiteConfiguration.DefaultSiteCulture.Name].Returns(DefultCultureStub.BuildSerialisedString());
        }
Exemplo n.º 9
0
        public void WhenTypedGetItemIsCalled_ThenTheReturnedItem_IsCorrect()
        {
            //Assign
            const long id = 1L;

            const string propityValue = "NotDefault Value";
            var          fi           = new FurnaceItemInformation <long>();
            var          returnJon    = new Stub
            {
                FurnaceItemInformation = fi,
                Test = propityValue
            }.BuildSerialisedString();

            var key = RedisBackedFurnaceItems.CreateItemKey(id, typeof(Stub));

            Client.Hashes[key][Arg.Any <string>()].Returns(returnJon);

            //Act
            var result = Sut.GetItem <Stub>(id);

            //Assert
            Assert.That(result.Test, Is.EqualTo(propityValue));
        }
Exemplo n.º 10
0
        private void AddChild <T>(long parentId, Type parenType, long childId, string test)
            where T : BaseStub, new()
        {
            var type        = typeof(T);
            var contentType = new ContentType {
                Name = type.Name, Namespace = type.Namespace
            };

            var furnaceItemInformation = new FurnaceItemInformation <long>
            {
                Id = childId,
                ContentTypeFullName       = contentType.FullName,
                ParentId                  = parentId,
                ParentContentTypeFullName = parenType.FullName
            };

            var stub = new T
            {
                FurnaceItemInformation = furnaceItemInformation,
                Test = test
            };

            var itemKey = RedisBackedFurnaceItems.CreateItemKey(furnaceItemInformation.Id, type);
            var setKey  = RedisBackedFurnaceItems.CreateItemChildrenKey(parentId, parenType);

            _childSortedSet.Add(itemKey);

            Client.Hashes[itemKey][SiteConfiguration.DefaultSiteCulture.Name].Returns(stub.BuildSerialisedString());
            Client.SortedSets[setKey].Returns(_childSortedSet);

            if (_contentTypes.All(x => x.FullName != contentType.FullName))
            {
                _contentTypes.Add(contentType);
            }

            ContentTypes.GetContentTypes().Returns(_contentTypes);
        }
Exemplo n.º 11
0
 public void SetFurnaceItem(FurnaceItemInformation itemInformation)
 {
     FurnaceItemInformation = itemInformation;
 }
Exemplo n.º 12
0
        public void WhenTypedGetItemIsCalled_ThenTheReturnedItem_IsCorrect()
        {
            //Assign
            const long id = 1L;

            const string propityValue = "NotDefault Value";
            var fi = new FurnaceItemInformation<long>();
            var returnJon = new Stub
            {
                FurnaceItemInformation = fi,
                Test = propityValue
            }.BuildSerialisedString();

            var key = RedisBackedFurnaceItems.CreateItemKey(id, typeof(Stub));

            Client.Hashes[key][Arg.Any<string>()].Returns(returnJon);

            //Act
            var result = Sut.GetItem<Stub>(id);

            //Assert
            Assert.That(result.Test, Is.EqualTo(propityValue));
        }
Exemplo n.º 13
0
        public void WhenGetItemIsCalled_ThenTheReturnedItem_IsCorrect()
        {
            //Assign
            const long id = 1L;
            ContentType.AddPropity("Test", "string");
            var item = Sut.CreateItem(ContentType);
            item.Id = id;

            const string propityValue = "NotDefaultValue";
            var fi = new FurnaceItemInformation<long>() {Id = id};
            var returnJson = new Stub
            {
                FurnaceItemInformation = fi,
                Test = propityValue
            }.BuildSerialisedString();

            var key = RedisBackedFurnaceItems.CreateItemKey(id, ContentType);

            Client.Hashes[key][SiteConfiguration.DefaultSiteCulture.Name].Returns(returnJson);

            //Act
            var result = Sut.GetItem(id, ContentType);

            //Assert
            Assert.That(result.Id, Is.EqualTo(id));
            Assert.That(result["Test"], Is.EqualTo(propityValue));
            Assert.That(result.ContentType.Name == ContentTypeName);
        }
Exemplo n.º 14
0
 public void GivenJapaneseAsTheCultureSetUp()
 {
     CultureInfo = CultureInfo.GetCultureInfo("fr-FR");
     var fi = new FurnaceItemInformation<long>();
     CultureStub = new Stub
     {
         FurnaceItemInformation = fi,
         Test = "こんにいちわ"
     };
 }
Exemplo n.º 15
0
 public void SetFurnaceItem(FurnaceItemInformation itemInformation)
 {
     FurnaceItemInformation = itemInformation;
 }