void ImmutableCollectionExample() { var source = new char[] { 'A' }; var immutableCollection = new MikValSor.Immutable.ImmutableCollection <char>(source); //Change the source source[0] = 'B'; //ImmutableCollection is the same System.Console.WriteLine($"immutableCollection[0]: {immutableCollection[0]}"); }
public void ImmutableValidator_ImmutableCollection_Assumption() { //Arrange var source = new char[] { 'A' }; var readonlyCollection = new MikValSor.Immutable.ImmutableCollection <char>(source); //Act source[0] = 'B'; //Assert Assert.Equal('A', readonlyCollection[0]); }
public void IsImmutable_object_ImmutableCollectionCharList() { //Arrange var validator = new ImmutableValidator(); var source = new List <char>[] { new List <char>(), new List <char>() }; var target = new MikValSor.Immutable.ImmutableCollection <List <char> >(source); //Act var actual = validator.IsImmutable(target); //Assert Assert.False(actual); }
public void IsImmutable_object_ImmutableCollectionObject() { //Arrange var validator = new ImmutableValidator(); var source = new object[] { new object(), new object() }; var target = new MikValSor.Immutable.ImmutableCollection <object>(source); //Act validator.EnsureImmutable(target); var actual = validator.IsImmutable(target); //Assert Assert.True(actual); }