From 732fe523f2e109c06655f6dc11a9227b22a2fa43 Mon Sep 17 00:00:00 2001 From: marianoor Date: Sun, 8 Nov 2009 12:22:30 +0000 Subject: [PATCH] Fixed #206: Linq-to-Mocks never returns on implicit Boolean property. Added support to negation of implicit Boolean property. ExpressionVisitor method names and visibility changed to adecuate it to the .NET Framework 4.0 ExpressionVisitor. Guard now receives an Expression to get the parameter name. git-svn-id: http://moq.googlecode.com/svn/trunk@641 b33fba48-7441-0410-8d5c-f397f7ceaa6c --- Moq.sln | 40 +- Source.Silverlight/Moq.Silverlight.csproj | 72 ++ Source/AdvancedMatcherAttribute.cs | 18 +- Source/Evaluator.cs | 1 - Source/ExpressionExtensions.cs | 13 +- Source/Extensions.cs | 7 +- Source/FluentMockContext.cs | 16 +- Source/Guard.cs | 55 +- Source/Interceptor.cs | 1 - Source/Linq/ExpressionReplacer.cs | 84 +- Source/Linq/Query.cs | 150 ++- Source/Linq/QueryProvider.cs | 19 +- Source/Linq/TypeHelper.cs | 4 +- Source/MethodCall.Legacy.cs | 9 +- Source/Microsoft/ExpressionVisitor.cs | 941 +++++++++--------- Source/Mock.Generic.cs | 17 +- Source/Mock.cs | 82 +- Source/Mocks.cs | 217 ++-- Source/Moq.csproj | 97 +- Source/Protected/ProtectedExtension.cs | 2 +- Source/Protected/ProtectedMock.cs | 20 +- Source/Times.cs | 10 +- .../Moq.Silverlight.Tests.csproj | 66 ++ UnitTests/AdvancedMatcherAttributeFixture.cs | 11 +- UnitTests/MockedEventsFixture.cs | 61 +- UnitTests/Moq.Tests.csproj | 79 +- UnitTests/QueryableMocksFixture.cs | 50 +- 27 files changed, 1144 insertions(+), 998 deletions(-) diff --git a/Moq.sln b/Moq.sln index c1f2bbc66..574db7ba4 100644 --- a/Moq.sln +++ b/Moq.sln @@ -20,40 +20,72 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x86 = Debug|x86 + Debug35|Any CPU = Debug35|Any CPU + Debug35|x86 = Debug35|x86 Release|Any CPU = Release|Any CPU Release|x86 = Release|x86 + Release35|Any CPU = Release35|Any CPU + Release35|x86 = Release35|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug|x86.ActiveCfg = Debug|x86 - {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug|x86.Build.0 = Debug|x86 + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug35|Any CPU.Build.0 = Debug35|Any CPU + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Debug35|x86.ActiveCfg = Debug35|Any CPU {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release|Any CPU.ActiveCfg = Release|Any CPU {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release|Any CPU.Build.0 = Release|Any CPU - {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release|x86.ActiveCfg = Release|x86 - {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release|x86.Build.0 = Release|x86 + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release|x86.ActiveCfg = Release|Any CPU + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release35|Any CPU.ActiveCfg = Release35|Any CPU + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release35|Any CPU.Build.0 = Release35|Any CPU + {1C91AC30-5977-4BE5-BA67-8EB186C03514}.Release35|x86.ActiveCfg = Release35|Any CPU {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug|x86.ActiveCfg = Debug|x86 {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug|x86.Build.0 = Debug|x86 + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug35|Any CPU.Build.0 = Debug35|Any CPU + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug35|x86.ActiveCfg = Debug35|x86 + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Debug35|x86.Build.0 = Debug35|x86 {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release|Any CPU.Build.0 = Release|Any CPU {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release|x86.ActiveCfg = Release|x86 {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release|x86.Build.0 = Release|x86 + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release35|Any CPU.ActiveCfg = Release35|Any CPU + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release35|Any CPU.Build.0 = Release35|Any CPU + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release35|x86.ActiveCfg = Release35|x86 + {81BBC911-4916-4E10-A955-752AE47CB2B9}.Release35|x86.Build.0 = Release35|x86 {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug|Any CPU.Build.0 = Debug|Any CPU {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug|x86.ActiveCfg = Debug|x86 {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug|x86.Build.0 = Debug|x86 + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug35|Any CPU.Build.0 = Debug35|Any CPU + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug35|x86.ActiveCfg = Debug35|x86 + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Debug35|x86.Build.0 = Debug35|x86 {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Release|Any CPU.ActiveCfg = Release|Any CPU {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Release|Any CPU.Build.0 = Release|Any CPU {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Release|x86.ActiveCfg = Release|Any CPU + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Release35|Any CPU.ActiveCfg = Release35|Any CPU + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Release35|Any CPU.Build.0 = Release35|Any CPU + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Release35|x86.ActiveCfg = Release35|x86 + {5136C8E1-E17F-481F-B29A-C7FAB528BD2D}.Release35|x86.Build.0 = Release35|x86 {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug|x86.ActiveCfg = Debug|x86 {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug|x86.Build.0 = Debug|x86 + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug35|Any CPU.ActiveCfg = Debug35|Any CPU + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug35|Any CPU.Build.0 = Debug35|Any CPU + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug35|x86.ActiveCfg = Debug35|x86 + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Debug35|x86.Build.0 = Debug35|x86 {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Release|Any CPU.Build.0 = Release|Any CPU {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Release|x86.ActiveCfg = Release|Any CPU + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Release35|Any CPU.ActiveCfg = Release35|Any CPU + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Release35|Any CPU.Build.0 = Release35|Any CPU + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Release35|x86.ActiveCfg = Release35|x86 + {02A2F6A6-D8CF-45EB-A424-BFD8C26034CE}.Release35|x86.Build.0 = Release35|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source.Silverlight/Moq.Silverlight.csproj b/Source.Silverlight/Moq.Silverlight.csproj index 812d83dc1..fee494633 100644 --- a/Source.Silverlight/Moq.Silverlight.csproj +++ b/Source.Silverlight/Moq.Silverlight.csproj @@ -410,6 +410,78 @@ $(SilverlightBuildResources)Libraries\Client\ 2.0.31005.0 + + true + bin\Debug35\ + TRACE;DEBUG;SILVERLIGHT + bin\Debug\Moq.Silverlight.xml + true + full + AnyCPU + bin\Debug\Moq.Silverlight.dll.CodeAnalysisLog.xml + bin\Debug35\Moq.Silverlight.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + true + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + true + true + + + true + bin\x86\Debug35\ + DEBUG;TRACE;SILVERLIGHT + bin\Debug\Moq.Silverlight.xml + true + full + x86 + bin\Debug\Moq.Silverlight.dll.CodeAnalysisLog.xml + bin\x86\Debug35\Moq.Silverlight.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + + + bin\Release35\ + TRACE;SILVERLIGHT;NET35 + bin\Release\Moq.Silverlight.xml + true + true + pdbonly + AnyCPU + bin\Release\Moq.Silverlight.dll.CodeAnalysisLog.xml + bin\Release35\Moq.Silverlight.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + true + + + bin\x86\Release35\ + TRACE;SILVERLIGHT + bin\Release\Moq.Silverlight.xml + true + true + pdbonly + x86 + bin\Release\Moq.Silverlight.dll.CodeAnalysisLog.xml + bin\x86\Release35\Moq.Silverlight.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + - - - diff --git a/Source/Protected/ProtectedExtension.cs b/Source/Protected/ProtectedExtension.cs index 80ec8829e..f6bdb0363 100644 --- a/Source/Protected/ProtectedExtension.cs +++ b/Source/Protected/ProtectedExtension.cs @@ -57,7 +57,7 @@ public static class ProtectedExtension public static IProtectedMock Protected(this Mock mock) where T : class { - Guard.ArgumentNotNull(mock, "mock"); + Guard.NotNull(() => mock, mock); return new ProtectedMock(mock); } diff --git a/Source/Protected/ProtectedMock.cs b/Source/Protected/ProtectedMock.cs index 7ffa77cee..4b58572a5 100644 --- a/Source/Protected/ProtectedMock.cs +++ b/Source/Protected/ProtectedMock.cs @@ -60,7 +60,7 @@ public ProtectedMock(Mock mock) public ISetup Setup(string voidMethodName, params object[] args) { - Guard.ArgumentNotNullOrEmptyString(voidMethodName, "voidMethodName"); + Guard.NotNullOrEmpty(() => voidMethodName, voidMethodName); var method = typeof(T).GetMethod(voidMethodName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, @@ -86,7 +86,7 @@ public ISetup Setup(string voidMethodName, params object[] args) } else { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, + throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.UnsupportedProtectedProperty, property.ReflectedType.Name, property.Name)); @@ -95,7 +95,7 @@ public ISetup Setup(string voidMethodName, params object[] args) public ISetup Setup(string methodOrPropertyName, params object[] args) { - Guard.ArgumentNotNullOrEmptyString(methodOrPropertyName, "methodOrPropertyName"); + Guard.NotNullOrEmpty(() => methodOrPropertyName, methodOrPropertyName); var method = typeof(T).GetMethod(methodOrPropertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, @@ -132,7 +132,7 @@ public ISetup Setup(string methodOrPropertyName, params obj public ISetupGetter SetupGet(string propertyName) { - Guard.ArgumentNotNullOrEmptyString(propertyName, "propertyName"); + Guard.NotNullOrEmpty(() => propertyName, propertyName); var property = typeof(T).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); @@ -149,7 +149,7 @@ public ISetupGetter SetupGet(string propertyName) public ISetupSetter SetupSet(string propertyName) { - Guard.ArgumentNotNullOrEmptyString(propertyName, "propertyName"); + Guard.NotNullOrEmpty(() => propertyName, propertyName); var property = typeof(T).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); @@ -169,13 +169,13 @@ private static void VerifyMethod(MethodInfo method) if (method != null) { if (method.IsPublic) - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, + throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.MethodIsPublic, method.ReflectedType.Name, method.Name)); if (method.IsAssembly || method.IsFamilyAndAssembly) - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, + throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.SetupOnNonOverridableMember, method.ReflectedType.Name + "." + method.Name)); } @@ -187,7 +187,7 @@ private static void VerifyProperty(PropertyInfo property) ((property.CanRead && property.GetGetMethod() != null || (property.CanWrite && property.GetSetMethod() != null)))) { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, + throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.UnexpectedPublicProperty, property.ReflectedType.Name, property.Name)); @@ -277,7 +277,7 @@ private static void ThrowIfPropertyMissing(string propertyName, PropertyInfo pro { if (property == null) { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, + throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.MemberMissing, typeof(T).Name, propertyName)); } @@ -287,7 +287,7 @@ private static void ThrowIfMemberMissing(string memberName, MethodInfo method, P { if (method == null && property == null) { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, + throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.MemberMissing, typeof(T).Name, memberName)); } diff --git a/Source/Times.cs b/Source/Times.cs index a24aee857..d9ff91241 100644 --- a/Source/Times.cs +++ b/Source/Times.cs @@ -69,7 +69,7 @@ private Times(Func evaluator, int from, int to, string messageFormat) /// An object defining the allowed number of invocations. public static Times AtLeast(int callCount) { - Guard.ArgumentNotOutOfRangeInclusive(callCount, 1, int.MaxValue, "callCount"); + Guard.NotOutOfRangeInclusive(() => callCount, callCount, 1, int.MaxValue); return new Times(c => c >= callCount, callCount, int.MaxValue, Resources.NoMatchingCallsAtLeast); } @@ -90,7 +90,7 @@ public static Times AtLeastOnce() /// An object defining the allowed number of invocations. public static Times AtMost(int callCount) { - Guard.ArgumentNotOutOfRangeInclusive(callCount, 0, int.MaxValue, "callCount"); + Guard.NotOutOfRangeInclusive(() => callCount, callCount, 0, int.MaxValue); return new Times(c => c >= 0 && c <= callCount, 0, callCount, Resources.NoMatchingCallsAtMost); } @@ -116,7 +116,7 @@ public static Times Between(int callCountFrom, int callCountTo, Range rangeKind) { if (rangeKind == Range.Exclusive) { - Guard.ArgumentNotOutOfRangeExclusive(callCountFrom, 0, callCountTo, "callCountFrom"); + Guard.NotOutOfRangeExclusive(() => callCountFrom, callCountFrom, 0, callCountTo); if (callCountTo - callCountFrom == 1) { throw new ArgumentOutOfRangeException("callCountTo"); @@ -129,7 +129,7 @@ public static Times Between(int callCountFrom, int callCountTo, Range rangeKind) Resources.NoMatchingCallsBetweenExclusive); } - Guard.ArgumentNotOutOfRangeInclusive(callCountFrom, 0, callCountTo, "callCountFrom"); + Guard.NotOutOfRangeInclusive(() => callCountFrom, callCountFrom, 0, callCountTo); return new Times( c => c >= callCountFrom && c <= callCountTo, callCountFrom, @@ -144,7 +144,7 @@ public static Times Between(int callCountFrom, int callCountTo, Range rangeKind) /// An object defining the allowed number of invocations. public static Times Exactly(int callCount) { - Guard.ArgumentNotOutOfRangeInclusive(callCount, 0, int.MaxValue, "callCount"); + Guard.NotOutOfRangeInclusive(() => callCount, callCount, 0, int.MaxValue); return new Times(c => c == callCount, callCount, callCount, Resources.NoMatchingCallsExactly); } diff --git a/UnitTests.Silverlight/Moq.Silverlight.Tests.csproj b/UnitTests.Silverlight/Moq.Silverlight.Tests.csproj index f4004219d..c1e9931fa 100644 --- a/UnitTests.Silverlight/Moq.Silverlight.Tests.csproj +++ b/UnitTests.Silverlight/Moq.Silverlight.Tests.csproj @@ -233,6 +233,72 @@ $(SilverlightBuildResources)Libraries\Client\ 2.0.31005.0 + + true + bin\Debug35\ + DEBUG;TRACE;SILVERLIGHT + true + full + AnyCPU + bin\Debug\Moq.Silverlight.Tests.dll.CodeAnalysisLog.xml + bin\Debug35\Moq.Silverlight.Tests.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + true + + + true + bin\x86\Debug35\ + DEBUG;TRACE;SILVERLIGHT + true + full + x86 + bin\x86\Debug\Moq.Silverlight.Tests.dll.CodeAnalysisLog.xml + bin\x86\Debug35\Moq.Silverlight.Tests.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + + + bin\Release35\ + TRACE;SILVERLIGHT + true + true + pdbonly + AnyCPU + bin\Release\Moq.Silverlight.Tests.dll.CodeAnalysisLog.xml + bin\Release35\Moq.Silverlight.Tests.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + true + + + bin\x86\Release35\ + TRACE;SILVERLIGHT + true + true + pdbonly + x86 + bin\x86\Release\Moq.Silverlight.Tests.dll.CodeAnalysisLog.xml + bin\x86\Release35\Moq.Silverlight.Tests.dll + true + GlobalSuppressions.cs + prompt + AllRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + diff --git a/UnitTests/QueryableMocksFixture.cs b/UnitTests/QueryableMocksFixture.cs index 3f7140691..01cb161fe 100644 --- a/UnitTests/QueryableMocksFixture.cs +++ b/UnitTests/QueryableMocksFixture.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using Xunit; namespace Moq.Tests @@ -89,6 +86,50 @@ where f.Bar.Baz("hey").Value == 5 Assert.Equal(instance2.Bar.Baz("hey").Value, 5); } + [Fact] + public void ShouldSupportBooleanExpression() + { + var instance = (from f in Mocks.CreateQuery() + where f.IsValid + select f) + .First(); + + Assert.True(instance.IsValid); + } + + [Fact] + public void ShouldSupportNotBooleanExpression() + { + var instance = (from f in Mocks.CreateQuery() + where !f.IsValid + select f) + .First(); + + Assert.False(instance.IsValid); + } + + [Fact] + public void ShouldSupportBooleanEqualsToTrue() + { + var instance = (from f in Mocks.CreateQuery() + where f.IsValid == true + select f) + .First(); + + Assert.True(instance.IsValid); + } + + [Fact] + public void ShouldSupportBooleanEqualsToFalse() + { + var instance = (from f in Mocks.CreateQuery() + where f.IsValid == false + select f) + .First(); + + Assert.False(instance.IsValid); + } + public interface IFoo { IBar Bar { get; set; } @@ -107,6 +148,7 @@ public interface IBaz { int Value { get; set; } int this[string key1, bool key2] { get; set; } + bool IsValid { get; set; } } } }