public void Preparation() { _container = MockHelper.InitializeContainer(AssembliesWhichShouldProvideExport, new Type[0]); _singleModel = new Model { Element = Guid.Empty, Key = Guid.NewGuid(), Name = "SingleModel" }; _singleElement = new Element() { Model = Guid.Empty, Key = Guid.NewGuid(), Name = "SingleElement" }; _dependentModel = new Model { Element = Guid.NewGuid(), Key = Guid.NewGuid(), Name = "DepModel" }; _dependentElement = new Element() { Model = _dependentModel.Key, Key = _dependentModel.Element, Name = "DepElement" }; var pool = new ResourcePool(); pool.Models.Add(_singleModel.Key, _singleModel); pool.Models.Add(_dependentModel.Key, _dependentModel); pool.Elements.Add(_singleElement.Key, _singleElement); pool.Elements.Add(_dependentElement.Key, _dependentElement); _container.ComposeExportedValue(pool); _container.ComposeExportedValue(_container); Settings.NoCacheGarbageChecking = true; }
public void SeriesTest() { var target = CreateITransientCachier(); var elements = MockHelper.GetRandomSequence <Guid>(300).ToDictionary(k => k, k => new Element { Key = k, Name = k.ToString() }); foreach (var element in elements) { target.Post(element.Key, element.Value); } var gotElements = target.Get <Element>(elements.Select(k => k.Key)); MockHelper.CheckSequences(elements.OrderBy(k => k.Key).Select(k => k.Value).ToArray(), gotElements.OrderBy(k => k.Key).ToArray()); Assert.IsTrue(ElementGetter.WasChanged); ElementGetter.WasChanged = false; gotElements = target.Get <Element>(elements.Select(k => k.Key)); MockHelper.CheckSequences(elements.OrderBy(k => k.Key).Select(k => k.Value).ToArray(), gotElements.OrderBy(k => k.Key).ToArray()); Assert.IsTrue(!ElementGetter.WasChanged); }