public void TestThatTranslateSetsTranslationToNullWhenIdentifierOnTranslatableBaseIsNull()
        {
            var translatable = new MyTranslatable();

            Assert.That(translatable, Is.Not.Null);
            Assert.That(translatable.Identifier, Is.Null);
            Assert.That(translatable.Identifier.HasValue, Is.False);

            translatable.Initialize(Guid.NewGuid());
            Assert.That(translatable.Translations, Is.Not.Null);
            Assert.That(translatable.Translations, Is.Not.Empty);

            translatable.Translate(CultureInfo.CurrentUICulture);
            Assert.That(translatable.Translation, Is.Null);
        }
        public void TestThatTranslateSetsTranslationToNullWhenTranslationCollectionDoesNotContainIdentifierFromTranslatableBase()
        {
            var translatable = new MyTranslatable
            {
                Identifier = Guid.NewGuid()
            };

            Assert.That(translatable, Is.Not.Null);
            Assert.That(translatable.Identifier, Is.Not.Null);
            Assert.That(translatable.Identifier.HasValue, Is.True);

            translatable.Initialize(Guid.NewGuid());
            Assert.That(translatable.Translations, Is.Not.Null);
            Assert.That(translatable.Translations, Is.Not.Empty);

            translatable.Translate(CultureInfo.CurrentUICulture);
            Assert.That(translatable.Translation, Is.Null);
        }
        public void TestThatTranslateCallsOnTranslation()
        {
            var translatable = new MyTranslatable
            {
                Identifier = Guid.NewGuid()
            };

            Assert.That(translatable, Is.Not.Null);
            Assert.That(translatable.Identifier, Is.Not.Null);
            Assert.That(translatable.Identifier.HasValue, Is.True);

            // ReSharper disable PossibleInvalidOperationException
            translatable.Initialize(translatable.Identifier.Value);
            // ReSharper restore PossibleInvalidOperationException
            Assert.That(translatable.Translations, Is.Not.Null);
            Assert.That(translatable.Translations, Is.Not.Empty);

            Assert.That(translatable.OnTranslateWasCalled, Is.False);
            translatable.Translate(translatable.Translations.First().TranslationInfo.CultureInfo);
            Assert.That(translatable.OnTranslateWasCalled, Is.True);
        }
        public void TestThatTranslateSetsTranslationWhenTranslationCollectionDoesNotContainsCultureTranslation(string notTranslatedCultureName)
        {
            var notTranslatedCulture = new CultureInfo(notTranslatedCultureName);

            var translatable = new MyTranslatable
            {
                Identifier = Guid.NewGuid()
            };

            Assert.That(translatable, Is.Not.Null);
            Assert.That(translatable.Identifier, Is.Not.Null);
            Assert.That(translatable.Identifier.HasValue, Is.True);

            // ReSharper disable PossibleInvalidOperationException
            translatable.Initialize(translatable.Identifier.Value);
            // ReSharper restore PossibleInvalidOperationException
            Assert.That(translatable.Translations, Is.Not.Null);
            Assert.That(translatable.Translations, Is.Not.Empty);

            translatable.Translate(notTranslatedCulture);
            Assert.That(translatable.Translation, Is.Not.Null);
        }
        public void TestThatTranslateSetsTranslationWhenTranslationCollectionContainsCultureTranslation()
        {
            var translatable = new MyTranslatable
            {
                Identifier = Guid.NewGuid()
            };

            Assert.That(translatable, Is.Not.Null);
            Assert.That(translatable.Identifier, Is.Not.Null);
            Assert.That(translatable.Identifier.HasValue, Is.True);

            // ReSharper disable PossibleInvalidOperationException
            translatable.Initialize(translatable.Identifier.Value);
            // ReSharper restore PossibleInvalidOperationException
            Assert.That(translatable.Translations, Is.Not.Null);
            Assert.That(translatable.Translations, Is.Not.Empty);

            foreach (var translation in translatable.Translations)
            {
                translatable.Translate(translation.TranslationInfo.CultureInfo);
                Assert.That(translatable.Translation, Is.Not.Null);
                Assert.That(translatable.Translation, Is.EqualTo(translation));
            }
        }