/// <summary> /// Initializes a new instance of the <see cref="InitialSafeObjectSettings"/> class. /// </summary> /// <param name="initialValue">The initial value.</param> /// <param name="isReadOnly">if set to <c>false</c> the instance will be modifiable initially.</param> /// <param name="protectionMode">The initial protection mode.</param> /// <param name="alertChannel">Gets/sets the alert channel for the inner <see cref="IInjectionDetector"/></param> public InitialSafeObjectSettings(object initialValue, bool isReadOnly, SafeObjectProtectionMode protectionMode, InjectionAlertChannel alertChannel) { InitialValue = initialValue; IsReadOnly = isReadOnly; ProtectionMode = protectionMode; AlertChannel = alertChannel; }
public MemoryCachedSafeByteFactory(SafeObjectProtectionMode innerDictionaryProtectionMode) : this( SafeOrbitCore.Current.Factory.Get <IByteIdGenerator>(), SafeOrbitCore.Current.Factory.Get <IFactory <ISafeByte> >(), SafeOrbitCore.Current.Factory.Get <ISafeObjectFactory>(), innerDictionaryProtectionMode) { }
internal MemoryCachedSafeByteFactory(IByteIdGenerator byteIdGenerator, IFactory <ISafeByte> safeByteFactory, ISafeObjectFactory safeObjectFactory, SafeObjectProtectionMode protectionMode) { _byteIdGenerator = byteIdGenerator ?? throw new ArgumentNullException(nameof(byteIdGenerator)); _safeByteFactory = safeByteFactory ?? throw new ArgumentNullException(nameof(safeByteFactory)); _safeObjectFactory = safeObjectFactory; _innerDictionaryProtectionMode = protectionMode; }
private static ISafeByteFactory GetSut(SafeObjectProtectionMode innerDictionaryProtectionMode = MemoryCachedSafeByteFactory.DefaultInnerDictionaryProtection, InjectionAlertChannel alertChannel = Defaults.AlertChannel) { return(new MemoryCachedSafeByteFactory( Stubs.Get <IByteIdGenerator>(), Stubs.GetFactory <ISafeByte>(), Stubs.Get <ISafeObjectFactory>(), innerDictionaryProtectionMode )); }
private static ISafeByteFactory GetSut( SafeObjectProtectionMode innerDictionaryProtectionMode = MemoryCachedSafeByteFactory.DefaultInnerDictionaryProtection, ISafeObjectFactory factory = null, IByteIdGenerator byteIdGenerator = null) { return(new MemoryCachedSafeByteFactory( byteIdGenerator ?? Stubs.Get <IByteIdGenerator>(), Stubs.GetFactory <ISafeByte>(), factory ?? Stubs.Get <ISafeObjectFactory>(), innerDictionaryProtectionMode )); }
public void Constructor_Sets_Inner_SafeObject_From_ProtectionMode(SafeContainerProtectionMode protectionMode, SafeObjectProtectionMode expected) { //arrange var safeObjectMock = new Mock <ISafeObject <Dictionary <string, IInstanceProvider> > >(); safeObjectMock.Setup(m => m.Object).Returns(new Dictionary <string, IInstanceProvider>()); var safeObjectFactory = new Mock <ISafeObjectFactory>(); safeObjectFactory.Setup( s => s.Get <Dictionary <string, IInstanceProvider> >(It.IsAny <IInitialSafeObjectSettings>())) .Returns <IInitialSafeObjectSettings>((settings) => safeObjectMock.Object); //act var sut = GetSut(protectionMode: protectionMode, safeObjectFactory: safeObjectFactory.Object); //assert safeObjectFactory.Verify( f => f.Get <Dictionary <string, IInstanceProvider> >( It.Is <IInitialSafeObjectSettings>(s => s.ProtectionMode.Equals(expected))), Times.Once); }