public void Return_CorrectValueFromFunc_WhenGenericMethod()
        {
            // Arrange
            TestPerson           instance    = this.fixture.Create <TestPerson>();
            Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory();
            Indexed sut = new Indexed(instance, true, factoryMock.Object);

            // Act & Assert
            Assert.AreSame(instance.Name, sut.Get <string>(nameof(TestPerson.Name)));
            Assert.AreEqual(instance.Age, sut.Get <int>(nameof(TestPerson.Age)));
        }
        public void Return_CorrectValueFromFunc_WhenAnonymousAndDynamic()
        {
            // Arrange
            dynamic instance = new
            {
                Name = this.fixture.Create <string>(),
                Age  = this.fixture.Create <int>()
            };
            Indexed sut = new Indexed(instance, true);

            // Act & Assert
            Assert.AreSame(instance.Name, sut.Get(nameof(instance.Name)));
            Assert.AreEqual(instance.Age, sut.Get(nameof(instance.Age)));
        }
        public void Throw_MissingMethodException_WhenShouldThrowOnMissingIsTrueAndMethodNotFound_WhenMethod()
        {
            // Arrange
            TestPerson           instance    = this.fixture.Create <TestPerson>();
            Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory();
            Indexed sut = new Indexed(instance, true, factoryMock.Object);

            // Act & Assert
            MissingMethodException ex = Assert.Throws <MissingMethodException>(() => sut.Get(TestConst.InvalidPropertyName));

            StringAssert.Contains(TestConst.InvalidPropertyName, ex.Message);
        }
        public void ReturnDefaultValue_WhenShouldThrowOnMissingIsTrueAndMethodNotFound_WhenGenericMethod()
        {
            // Arrange
            TestPerson           instance    = this.fixture.Create <TestPerson>();
            Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory();
            int     actual = -1;
            Indexed sut    = new Indexed(instance, false, factoryMock.Object);

            // Act & Assert
            Assert.DoesNotThrow(() =>
            {
                actual = sut.Get <int>(TestConst.InvalidPropertyName);
            });

            Assert.AreEqual(0, actual);
        }
        public void ReturnNull_WhenThrowOnMissingIsTrueAndMethodNotFound_WhenGenericMethod()
        {
            // Arrange
            TestPerson           instance    = this.fixture.Create <TestPerson>();
            Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory();
            string  actual = string.Empty;
            Indexed sut    = new Indexed(instance, false, factoryMock.Object);

            // Act & Assert
            Assert.DoesNotThrow(() =>
            {
                actual = sut.Get <string>(TestConst.InvalidPropertyName);
            });

            Assert.AreEqual(null, actual);
        }