public void DoubleLatestRequestRegistrationTest() { var containerMock = new Mock <IPandaContainer>(); var registration = new RequestProviderRegistration <ITestRequest>(containerMock.Object) .LatestRequest <TestRequestA>(); Should.Throw <InvalidOperationException>(() => registration.LatestRequest <TestRequestB>()); }
public void VersionSpecificRegistrationTest() { var containerMock = new Mock <IPandaContainer>(); var registration = new RequestProviderRegistration <ITestRequest>(containerMock.Object) .VersionSpecificRequest <TestRequestA>(new Version("1.0.1")) .VersionSpecificRequest <TestRequestB>(new Version("1.1.1")) .LatestRequest <TestRequestC>(); var lowerVersion = new PandaContainerContext(new Version("1.0.0")); registration.Register(lowerVersion); containerMock.Verify(c => c.RegisterType <ITestRequest>(typeof(TestRequestA))); containerMock.VerifyNoOtherCalls(); var middleVersion = new PandaContainerContext(new Version("1.0.6")); registration.Register(middleVersion); containerMock.Verify(c => c.RegisterType <ITestRequest>(typeof(TestRequestB))); containerMock.VerifyNoOtherCalls(); var higherVersion = new PandaContainerContext(new Version("1.2.1")); registration.Register(higherVersion); containerMock.Verify(c => c.RegisterType <ITestRequest>(typeof(TestRequestC))); containerMock.VerifyNoOtherCalls(); var matchedVersion = new PandaContainerContext(new Version("1.1.1")); registration.Register(matchedVersion); containerMock.Verify(c => c.RegisterType <ITestRequest>(typeof(TestRequestB))); containerMock.VerifyNoOtherCalls(); }