private RecordFormats Format(params Capability[] capabilities) { RecordFormats formats = mock(typeof(BaseRecordFormats)); when(formats.Capabilities()).thenReturn(capabilities); when(formats.HasCompatibleCapabilities(any(typeof(RecordFormats)), any(typeof(CapabilityType)))).thenCallRealMethod(); return(formats); }
public static bool HasCompatibleCapabilities(RecordFormats one, RecordFormats other, CapabilityType type) { ISet <Capability> myFormatCapabilities = Stream.of(one.Capabilities()).filter(capability => capability.isType(type)).collect(toSet()); ISet <Capability> otherFormatCapabilities = Stream.of(other.Capabilities()).filter(capability => capability.isType(type)).collect(toSet()); if (myFormatCapabilities.SetEquals(otherFormatCapabilities)) { // If they have the same capabilities then of course they are compatible return(true); } //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: bool capabilitiesNotRemoved = otherFormatCapabilities.containsAll(myFormatCapabilities); //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'removeAll' method: otherFormatCapabilities.removeAll(myFormatCapabilities); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: bool allAddedAreAdditive = otherFormatCapabilities.All(Capability::isAdditive); // Even if capabilities of the two aren't the same then there's a special case where if the additional // capabilities of the other format are all additive then they are also compatible because no data // in the existing store needs to be migrated. return(capabilitiesNotRemoved && allAddedAreAdditive); }