public void OrTypesWork() { var or = new FrontEndOrType( new Box <IOrType <IFrontendType <IVerifiableType>, IError> > (OrType.Make <IFrontendType <IVerifiableType>, IError>(new NumberType())), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(new StringType())), OrType.Make <IReadOnlyList <WeakMemberDefinition>, IError>(Array.Empty <WeakMemberDefinition>()), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >(), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >()); Assert.True(or.TheyAreUs(new NumberType(), new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); Assert.True(or.TheyAreUs(new StringType(), new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); Assert.False(new NumberType().TheyAreUs(or, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); Assert.False(new StringType().TheyAreUs(or, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); }
public void OrTypesJustNeedBothToMatchOne() { var a1 = A1(); var b1 = B1(); var b2 = B2(); var b3 = B3(); var or1 = new FrontEndOrType( new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a1)), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b1)), OrType.Make <IReadOnlyList <WeakMemberDefinition>, IError>(Array.Empty <WeakMemberDefinition>()), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >(), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >()); var or2 = new FrontEndOrType( new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b2)), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b3)), OrType.Make <IReadOnlyList <WeakMemberDefinition>, IError>(new List <WeakMemberDefinition> { new WeakMemberDefinition(Access.ReadWrite, new NameKey("bm1"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(new NumberType()))), new WeakMemberDefinition(Access.ReadWrite, new NameKey("bm2"), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(new NumberType()))) }), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >(), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >()); // this works since both b2 and b3 are b1 Assert.True(or1.TheyAreUs(or2, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); // this does not work because niether b2 nor b3 are a1 Assert.False(or2.TheyAreUs(or1, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); }
public void OrTypesAreVarient() { var a1 = A1(); var a2 = A2(); var b1 = B1(); var b2 = B2(); var or1 = new FrontEndOrType( new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a1)), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b1)), OrType.Make <IReadOnlyList <WeakMemberDefinition>, IError>(Array.Empty <WeakMemberDefinition>()), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >(), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >() ); var or2 = new FrontEndOrType( new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(a2)), new Box <IOrType <IFrontendType <IVerifiableType>, IError> >(OrType.Make <IFrontendType <IVerifiableType>, IError>(b2)), OrType.Make <IReadOnlyList <WeakMemberDefinition>, IError>(Array.Empty <WeakMemberDefinition>()), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >(), Possibly.IsNot <IBox <IOrType <IFrontendType <IVerifiableType>, IError> > >() ); Assert.True(or1.TheyAreUs(or2, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); Assert.False(or2.TheyAreUs(or1, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()).Is1OrThrow()); }