Esempio n. 1
0
        public void Constructor4_ValuesAsErrorsArgument_ShouldSetErrorsProperty()
        {
            var errors = Expectations.GetCompositionErrors();

            foreach (var e in errors)
            {
                var result = new CompositionResult <string>(e);

                EnumerableAssert.AreEqual(e, result.Errors);
            }
        }
Esempio n. 2
0
        public void GetEnumerator()
        {
            var dictionary         = GetWritableDictionaryWithData();
            var readOnlyDictionary = GetReadOnlyDictionary(dictionary);
            IEnumerable <KeyValuePair <string, object> > genericEnumerable = readOnlyDictionary;

            EnumerableAssert.AreEqual(genericEnumerable, dictionary);
            IEnumerable weakEnumerable = (IEnumerable)readOnlyDictionary;

            EnumerableAssert.AreEqual(weakEnumerable, dictionary);
        }
        public void Constructor_ValueAsDictionaryArgument_ShouldSetItemsProperty()
        {
            var expectations = Expectations.GetMetadata();

            foreach (var e in expectations)
            {
                var proxy = new ReadOnlyDictionaryDebuggerProxy <string, object>(CreateReadOnlyDictionary(e));

                EnumerableAssert.AreEqual(e, proxy.Items);
            }
        }
        public void Constructor2_DictionaryAsMetadataArgument_ShouldSetMetadataProperty()
        {
            var expectations = Expectations.GetMetadata();

            foreach (var e in expectations)
            {
                var definition = new ExportDefinition("Contract", e);

                EnumerableAssert.AreEqual(e, definition.Metadata);
            }
        }
Esempio n. 5
0
        public void Constructor2_ValueAsMetadataArgument_ShouldSetMetadataProperty()
        {
            var expectations = Expectations.GetMetadata();

            foreach (var e in expectations)
            {
                var definition = new ContractBasedImportDefinition("ContractName", (string)null, null, ImportCardinality.ExactlyOne, false, false, CreationPolicy.Any, e);

                EnumerableAssert.AreEqual(e, definition.Metadata);
            }
        }
Esempio n. 6
0
        public void Constructor4_DictionaryAsMetadataArgument_ShouldSetDefinitionMetadataProperty()
        {
            var expectations = Expectations.GetMetadata();

            foreach (var e in expectations)
            {
                var export = new Export("ContractName", e, () => null);

                EnumerableAssert.AreEqual(e, export.Definition.Metadata);
            }
        }
        public void Constructor5_ArrayAsAsErrorsArgument_ShouldNotAllowModificationAfterConstruction()
        {
            var error  = CreateCompositionError();
            var errors = new CompositionError[] { error };

            var exception = new CompositionException("Message", new Exception(), errors);

            errors[0] = null;

            EnumerableAssert.AreEqual(exception.Errors, error);
        }
        public void RequiredNonSharedImporter_ShouldFilterShared()
        {
            var container = CreateDefaultContainer();

            var importer = container.GetExportedValue <RequiredNonSharedImporter>();

            EnumerableAssert.AreEqual(
                importer.Exports.Select(obj => obj.GetType()),
                typeof(CreationPolicyAnyExportImplicit),
                typeof(CreationPolicyAnyExportExplicit),
                typeof(CreationPolicyNonSharedExport));
        }
        public void Constructor_ValueAsCatalogArgument_ShouldSetAssemblyProperty()
        {
            var expectations = Expectations.GetAssemblies();

            using (TemporaryFileCopier copier = new TemporaryFileCopier(expectations.Select(assembly => assembly.Location).ToArray()))
            {
                var catalog = CreateDirectoryCatalog(copier.DirectoryPath);
                var proxy   = new DirectoryCatalog.DirectoryCatalogDebuggerProxy(catalog);

                EnumerableAssert.AreEqual(expectations, proxy.Assemblies);
            }
        }
Esempio n. 10
0
        private static void AssertCanParse(Expression <Func <ExportDefinition, bool> > constraint, string contractName, IEnumerable <KeyValuePair <string, Type> > requiredMetadata)
        {
            Assert.IsNotNull(constraint);

            string contractNameResult = null;
            IEnumerable <KeyValuePair <string, Type> > requiredMetadataResult = null;
            bool success = ContraintParser.TryParseConstraint(constraint, out contractNameResult, out requiredMetadataResult);

            Assert.IsTrue(success);
            Assert.AreEqual(contractName, contractNameResult);
            EnumerableAssert.AreEqual(requiredMetadata, requiredMetadataResult);
        }
        public void TestFlatten()
        {
            IEnumerable <IEnumerable <int> > source = new[]
            {
                new[] { 1, 3, 7 },
                new[] { 2, 4 }
            };

            IEnumerable <int> flattened = source.Flatten();

            EnumerableAssert.AreEqual(new[] { 1, 3, 7, 2, 4 }, flattened);
        }
Esempio n. 12
0
        public void Metadata_DerivedExportDefinition_ShouldReturnDefinitionMetadata()
        {
            var expectations = Expectations.GetMetadata();

            foreach (var e in expectations)
            {
                var definition = ExportDefinitionFactory.Create("ContractName", e);

                var export = new DerivedExport(definition);

                EnumerableAssert.AreEqual(e, export.Metadata);
            }
        }
            public void then_session_is_updated_with_new_eventSources()
            {
                var currentEventSource = this.sinkSettings.EventSources.First();
                var newEventSource     = new EventSourceSettings(currentEventSource.Name, level: currentEventSource.Level, matchAnyKeyword: EventKeywords.AuditSuccess);

                this.Sut.UpdateSession(new List <EventSourceSettings> {
                    newEventSource
                });

                Assert.AreEqual(newEventSource.Level, currentEventSource.Level);
                Assert.AreEqual(newEventSource.MatchAnyKeyword, currentEventSource.MatchAnyKeyword);
                EnumerableAssert.AreEqual(newEventSource.Arguments, currentEventSource.Arguments);
                EnumerableAssert.AreEqual(newEventSource.ProcessNamesToFilter, currentEventSource.ProcessNamesToFilter);
            }
        public void ImportSingleIntoCollection()
        {
            var container = ContainerFactory.Create();
            var importer  = new Int32CollectionImporter();
            var exporter  = new Int32Exporter(42);

            CompositionBatch batch = new CompositionBatch();

            batch.AddPart(importer);
            batch.AddPart(exporter);
            container.Compose(batch);

            EnumerableAssert.AreEqual(importer.Values, 42);
        }
            public void VerifyImports(params T[] expectedValues)
            {
                // Fields
                EnumerableAssert.AreEqual(IEnumerableOfTField, expectedValues);
                EnumerableAssert.AreEqual(IEnumerableOfObjectField, expectedValues.Cast <object>());
                EnumerableAssert.AreEqual(ArrayOfTField, expectedValues);
                EnumerableAssert.AreEqual(ArrayOfObjectField, expectedValues.Cast <object>());

                // Properties
                EnumerableAssert.AreEqual(IEnumerableOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(IEnumerableOfObjectProperty, expectedValues.Cast <object>());
                EnumerableAssert.AreEqual(ArrayOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(ArrayOfObjectProperty, expectedValues.Cast <object>());
            }
        public void ImportCollectionsNameless()
        {
            // Verifing that the contract name gets the correct value
            var container               = ContainerFactory.Create();
            NamelessImporter importer   = new NamelessImporter();
            NamelessExporter exporter42 = new NamelessExporter(42);
            NamelessExporter exporter0  = new NamelessExporter(0);

            CompositionBatch batch = new CompositionBatch();

            batch.AddParts(importer, exporter42, exporter0);
            container.Compose(batch);

            EnumerableAssert.AreEqual(importer.ReadWriteIList, 42, 0);
        }
Esempio n. 17
0
        public void TestCircuitEvaluation()
        {
            BitArray[] inputs =
            {
                BitArray.FromBinaryString("0111010011"),
                BitArray.FromBinaryString("1101100010"),
                BitArray.FromBinaryString("0111110011")
            };

            Bit[] sequentialInput = inputs.SelectMany(bits => bits).ToArray();

            CircuitBuilder builder = new CircuitBuilder();
            SetIntersectionCircuitRecorder setIntersectionCircuitRecorder =
                new SetIntersectionCircuitRecorder(inputs.Length, inputs[0].Length);

            setIntersectionCircuitRecorder.Record(builder);

            Circuit        circuit        = builder.CreateCircuit();
            ForwardCircuit forwardCircuit = new ForwardCircuit(circuit);

            ICircuitEvaluator <Bit> evaluator = new LocalCircuitEvaluator();
            ReportingBatchCircuitEvaluator <Bit> batchCircuitEvaluator =
                new ReportingBatchCircuitEvaluator <Bit>(new BatchCircuitEvaluator <Bit>(evaluator));

            BitArray lazyEvaluationOutput     = new BitArray(circuit.Evaluate(evaluator, sequentialInput));
            BitArray forwardEvaluationOutput  = new BitArray(forwardCircuit.Evaluate(batchCircuitEvaluator, sequentialInput));
            BitArray expectedEvaluationOutput = BitArray.FromBinaryString("01010000101100");

            EnumerableAssert.AreEqual(
                expectedEvaluationOutput,
                lazyEvaluationOutput
                );

            EnumerableAssert.AreEqual(
                expectedEvaluationOutput,
                forwardEvaluationOutput
                );

            int[] actualBatchSizes   = batchCircuitEvaluator.BatchSizes;
            int[] expectedBatchSizes = { 10, 10, 9, 9, 8 };

            EnumerableAssert.AreEqual(
                expectedBatchSizes,
                actualBatchSizes
                );
        }
        public void ReadToEnd_Entire()
        {
            var bytes = new byte[] { 243, 75, 31, 139, 26 };

            using (var stream = new MemoryStream(bytes))
            {
                EnumerableAssert.AreEqual(bytes, stream.ReadToEnd());
                Assert.AreEqual(bytes.Length, stream.Position);
            }

            bytes = CachedRandom.Current.NextBytes(4 * 1024 * 1024);
            using (var stream = new MemoryStream(bytes))
            {
                EnumerableAssert.AreEqual(bytes, stream.ReadToEnd());
                Assert.AreEqual(bytes.Length, stream.Position);
            }
        }
            public void VerifyImport(params int[] expectedValues)
            {
                object[] untypedExpectedValues = expectedValues.Cast <object>().ToArray();

                ExportsAssert.AreEqual(CollectionPlain, untypedExpectedValues);
                ExportsAssert.AreEqual(CollectionPlainRawMetadata, untypedExpectedValues);
                EnumerableAssert.IsTrueForAll(CollectionPlainRawMetadata, i => true.Equals(i.Metadata["PropertyName"]));
                EnumerableAssert.IsEmpty(CollectionPlainEmpty);
                EnumerableAssert.IsEmpty(CollectionPlainEmptyRawMetadata);

                // Add a new Export to this collection to ensure that it doesn't
                // modifiy the other collections because they should each have there
                // own collection instance
                CollectionPlain.Add(ExportFactory.Create <object>("Value"));

                ExportsAssert.AreEqual(CollectionTyped, expectedValues);
                ExportsAssert.AreEqual(CollectionTypedRawMetadata, expectedValues);
                EnumerableAssert.IsTrueForAll(CollectionTypedRawMetadata, i => true.Equals(i.Metadata["PropertyName"]));
                EnumerableAssert.IsEmpty(CollectionTypedEmpty);

                ExportsAssert.AreEqual(CollectionTypedMetadata, expectedValues);
#if !SILVERLIGHT // Silverlight doesn't support strongly typed metadata
                EnumerableAssert.IsTrueForAll(CollectionTypedMetadata, i => true == i.Metadata.PropertyName);
#endif //!SILVERLIGHT
                EnumerableAssert.IsEmpty(CollectionTypedMetadataEmpty);

                EnumerableAssert.AreEqual(ReadWriteEnumerable, expectedValues);
                EnumerableAssert.IsEmpty(ReadWriteEnumerableEmpty);

                ExportsAssert.AreEqual(MetadataUntypedEnumerable, untypedExpectedValues);
                ExportsAssert.AreEqual(MetadataUntypedEnumerableRawMetadata, untypedExpectedValues);
                EnumerableAssert.IsTrueForAll(MetadataUntypedEnumerableRawMetadata, i => true.Equals(i.Metadata["PropertyName"]));
                EnumerableAssert.IsEmpty(MetadataUntypedEnumerableEmpty);
                EnumerableAssert.IsEmpty(MetadataUntypedEnumerableEmptyRawMetadata);

                ExportsAssert.AreEqual(MetadataTypedEnumerable, expectedValues);
                ExportsAssert.AreEqual(MetadataTypedEnumerableRawMetadata, expectedValues);
                EnumerableAssert.IsTrueForAll(MetadataTypedEnumerableRawMetadata, i => true.Equals(i.Metadata["PropertyName"]));
                EnumerableAssert.IsEmpty(MetadataTypedEnumerableEmpty);

                ExportsAssert.AreEqual(MetadataFullyTypedEnumerable, expectedValues);
#if !SILVERLIGHT // Silverlight doesn't support strongly typed metadata
                EnumerableAssert.IsTrueForAll(MetadataFullyTypedEnumerable, i => true == i.Metadata.PropertyName);
#endif //!SILVERLIGHT
                EnumerableAssert.IsEmpty(MetadataFullyTypedEnumerableEmpty);
            }
        public void Items_ShouldNotCacheUnderlyingItems()
        {
            var dictionary = new Dictionary <string, object>();

            dictionary.Add("Name", "Value");

            var proxy = new ReadOnlyDictionaryDebuggerProxy <string, object>(CreateReadOnlyDictionary(dictionary));

            EnumerableAssert.AreEqual(dictionary, proxy.Items);

            dictionary.Add("AnotherName", "Value");

            EnumerableAssert.AreEqual(dictionary, proxy.Items);

            dictionary.Add("AndAnotherName", "Value");

            EnumerableAssert.AreEqual(dictionary, proxy.Items);
        }
Esempio n. 21
0
        public void Sorting()
        {
            using (new CultureSwapper(PredefinedCulture.EnglishUnitedStates))
            {
                var cities = new[] { paris, newYork, athens, madrid, añasco };

                var sortedSet = new SortedSet <City>(cities, KeyComparer.Create((City city) => city.Name));
                EnumerableAssert.AreEqual(new[] { añasco, athens, madrid, newYork, paris }, sortedSet);

                sortedSet = new SortedSet <City>(cities, KeyComparer.Create((City city) => city.Name, StringComparer.Ordinal));
                EnumerableAssert.AreEqual(new[] { athens, añasco, madrid, newYork, paris }, sortedSet);
            }

            int[] nums  = new[] { 47, -32, -54, 18, 62, -71, 58 };
            var   byAbs = new SortedSet <int>(nums, KeyComparer.Create((int n) => Math.Abs(n)));

            EnumerableAssert.AreEqual(new [] { 18, -32, 47, -54, 58, 62, -71 }, byAbs);
        }
Esempio n. 22
0
        public void AddExport_ReturnedComposablePart_ContainsExportDefinitionRepresentingExport()
        {
            var metadata = new Dictionary <string, object>();

            metadata["Name"] = "Value";

            CompositionBatch batch = new CompositionBatch();
            var export             = ExportFactory.Create("Contract", "Value", metadata);

            var part = batch.AddExport(export);

            Assert.Equal(1, batch.PartsToAdd.Count);

            var definition = part.ExportDefinitions.Single();

            Assert.Equal("Contract", definition.ContractName);
            Assert.Equal("Value", part.GetExportedValue(definition));
            EnumerableAssert.AreEqual(metadata, definition.Metadata);
        }
            public void VerifyImports(params T[] expectedValues)
            {
                EnumerableAssert.AreEqual(ICollectionOfTReadOnlyField, expectedValues);
                EnumerableAssert.AreEqual(ListOfTField, expectedValues);
                EnumerableAssert.AreEqual(ListOfTReadOnlyField, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTField, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTReadOnlyField, expectedValues);

                EnumerableAssert.AreEqual(ICollectionOfTReadOnlyProperty, expectedValues);
                EnumerableAssert.AreEqual(ListOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(ListOfTReadOnlyProperty, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTReadOnlyProperty, expectedValues);

                EnumerableAssert.AreEqual(ObservableCollectionOfTField, expectedValues);
                EnumerableAssert.AreEqual(ObservableCollectionOfTReadOnlyField, expectedValues);
                EnumerableAssert.AreEqual(ObservableCollectionOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(ObservableCollectionOfTReadOnlyProperty, expectedValues);
            }
        public void ImportCollections_WriteOnlyArray()
        {
            var container = ContainerFactory.Create();
            var batch     = new CompositionBatch();

            var importer = new ImporterWriteOnlyArray();

            List <int> values = new List <int>()
            {
                21, 32, 43
            };

            batch.AddPart(importer);
            values.ForEach(v => batch.AddExportedValue("Value", v));

            container.Compose(batch);

            EnumerableAssert.AreEqual(values, importer.PublicArray);
        }
Esempio n. 25
0
        public void RebindingShouldNotHappenForConstructorArguments()
        {
            var container          = GetContainerWithCatalog();
            CompositionBatch batch = new CompositionBatch();

            var p1 = batch.AddExportedValue("MyConstructorCollectionItem", 1);

            batch.AddExportedValue("MyConstructorCollectionItem", 2);
            batch.AddExportedValue("MyConstructorCollectionItem", 3);
            container.Compose(batch);

            var a = container.GetExportedValue <AWithCollectionArgument>();

            EnumerableAssert.AreEqual(a.Values, 1, 2, 3);

            batch = new CompositionBatch();
            batch.AddExportedValue("MyConstructorCollectionItem", 4);
            batch.AddExportedValue("MyConstructorCollectionItem", 5);
            batch.AddExportedValue("MyConstructorCollectionItem", 6);
            // After rejection changes that are incompatible with existing assumptions are no
            // longer silently ignored.  The batch attempting to make this change is rejected
            // with a ChangeRejectedException
            CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PreventedByExistingImport, () =>
            {
                container.Compose(batch);
            });

            // The collection which is a constructor import should not be rebound
            EnumerableAssert.AreEqual(a.Values, 1, 2, 3);

            batch.RemovePart(p1);
            // After rejection changes that are incompatible with existing assumptions are no
            // longer silently ignored.  The batch attempting to make this change is rejected
            // with a ChangeRejectedException
            CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PreventedByExistingImport, () =>
            {
                container.Compose(batch);
            });

            // The collection which is a constructor import should not be rebound
            EnumerableAssert.AreEqual(a.Values, 1, 2, 3);
        }
            public void then_session_is_updated_with_new_eventSources_with_filters_and_arguments()
            {
                var currentEventSource = this.sinkSettings.EventSources.First();
                var newEventSource     =
                    new EventSourceSettings(
                        currentEventSource.Name,
                        level: currentEventSource.Level,
                        matchAnyKeyword: currentEventSource.MatchAnyKeyword,
                        arguments: new[] { new KeyValuePair <string, string>("key", "value") },
                        processNameFilters: new[] { "process" });

                this.Sut.UpdateSession(new List <EventSourceSettings> {
                    newEventSource
                });

                Assert.AreEqual(newEventSource.Level, currentEventSource.Level);
                Assert.AreEqual(newEventSource.MatchAnyKeyword, currentEventSource.MatchAnyKeyword);
                EnumerableAssert.AreEqual(newEventSource.Arguments, currentEventSource.Arguments);
                EnumerableAssert.AreEqual(newEventSource.ProcessNamesToFilter, currentEventSource.ProcessNamesToFilter);
            }
Esempio n. 27
0
        public void Person_SortedSet()
        {
            var persons = new[]
            {
                new Person {
                    Ssn = "324-00-3015", DateOfBirth = new DateTime(1970, 12, 17), FirstName = "Tod", LastName = "Temme"
                },
                new Person {
                    Ssn = "548-00-1592", DateOfBirth = new DateTime(1968, 03, 13), FirstName = "Lucia", LastName = "Armstrong"
                },
                new Person {
                    Ssn = "129-00-7416", DateOfBirth = new DateTime(1982, 09, 02), FirstName = "Spencer", LastName = "Weaver"
                },
                new Person {
                    Ssn = "831-00-6391", DateOfBirth = new DateTime(1974, 04, 30), FirstName = "Celia", LastName = "Potter"
                },
                new Person {
                    Ssn = "714-00-6502", DateOfBirth = new DateTime(1966, 11, 19), FirstName = "Powell", LastName = "Beck"
                },
            };

            var bySsn = new SortedSet <Person>(persons, KeyComparer.Create(
                                                   (Person p) => p.Ssn));

            // Not suitable for real-world scenarios, since SortedSet<T> does not allow duplicates.
            var byDateOfBirth = new SortedSet <Person>(persons, KeyComparer.Create(
                                                           (Person p) => p.DateOfBirth));
            var byFullName = new SortedSet <Person>(persons, KeyComparer.Create(
                                                        (Person p) => $"{p.FirstName} {p.LastName}", StringComparer.Ordinal));

            EnumerableAssert.AreEqual(new[] { "Spencer", "Tod", "Lucia", "Powell", "Celia" }, bySsn.Select(p => p.FirstName));
            EnumerableAssert.AreEqual(new[] { "Powell", "Lucia", "Tod", "Celia", "Spencer" }, byDateOfBirth.Select(p => p.FirstName));
            EnumerableAssert.AreEqual(new[] { "Celia", "Lucia", "Powell", "Spencer", "Tod" }, byFullName.Select(p => p.FirstName));

            var person = new Person {
                Ssn = "301-00-1582", DateOfBirth = new DateTime(1984, 11, 01), FirstName = "Teddy", LastName = "Wake"
            };

            bySsn.Add(person);
            EnumerableAssert.AreEqual(new[] { "Spencer", "Teddy", "Tod", "Lucia", "Powell", "Celia" }, bySsn.Select(p => p.FirstName));
        }
Esempio n. 28
0
        private static void PerformSecureComputation(IMultiPartyNetworkSession session, BitArray expectedOutput)
        {
            BitArray localInput = Inputs[session.LocalParty.Id];

            using CryptoContext cryptoContext = CryptoContext.CreateDefault();

            IObliviousTransfer obliviousTransfer = new NaorPinkasObliviousTransfer(
                new SecurityParameters(47, 23, 4, 1, 1),
                cryptoContext
                );

            IMultiplicativeSharing multiplicativeSharing = new ObliviousTransferMultiplicativeSharing(
                obliviousTransfer,
                cryptoContext
                );

            SecretSharingSecureComputation computation = new SecretSharingSecureComputation(
                session,
                multiplicativeSharing,
                cryptoContext
                );

            SetIntersectionCircuitRecorder circuitRecorder = new SetIntersectionCircuitRecorder(
                session.NumberOfParties,
                localInput.Length
                );

            CircuitBuilder circuitBuilder = new CircuitBuilder();

            circuitRecorder.Record(circuitBuilder);

            ForwardCircuit circuit      = new ForwardCircuit(circuitBuilder.CreateCircuit());
            BitArray       actualOutput = computation
                                          .EvaluateAsync(circuit, circuitRecorder.InputMapping, circuitRecorder.OutputMapping, localInput)
                                          .Result;

            EnumerableAssert.AreEqual(
                expectedOutput,
                actualOutput
                );
        }
            public void VerifyImports(params T[] expectedValues)
            {
                EnumerableAssert.AreEqual(ICollectionOfTReadOnlyField, expectedValues);
                EnumerableAssert.AreEqual(ListOfTField, expectedValues);
                EnumerableAssert.AreEqual(ListOfTReadOnlyField, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTField, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTReadOnlyField, expectedValues);

                EnumerableAssert.AreEqual(ICollectionOfTReadOnlyProperty, expectedValues);
                EnumerableAssert.AreEqual(ListOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(ListOfTReadOnlyProperty, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(CollectionOfTReadOnlyProperty, expectedValues);

#if FEATURE_OBSERVABLECOLLECTIONS
                EnumerableAssert.AreEqual(ObservableCollectionOfTField, expectedValues);
                EnumerableAssert.AreEqual(ObservableCollectionOfTReadOnlyField, expectedValues);
                EnumerableAssert.AreEqual(ObservableCollectionOfTProperty, expectedValues);
                EnumerableAssert.AreEqual(ObservableCollectionOfTReadOnlyProperty, expectedValues);
#endif // FEATURE_OBSERVABLECOLLECTIONS
            }
        public void ReadToEnd_FileStream()
        {
            using (var tempFile = new TempFile(create: false))
            {
                var filePath = tempFile.FilePath;
                var bytes    = CachedRandom.Current.NextBytes(16 * 1024);
                File.WriteAllBytes(filePath, bytes);

                using (var fileStream = File.OpenRead(filePath))
                {
                    EnumerableAssert.AreEqual(bytes, fileStream.ReadToEnd());
                }

                using (var fileStream = File.OpenRead(filePath))
                {
                    byte[] discard   = new byte[4 * 1024];
                    int    discarded = fileStream.Read(discard, 0, discard.Length);

                    EnumerableAssert.AreEqual(bytes.Skip(discarded), fileStream.ReadToEnd());
                }
            }
        }