Пример #1
0
 public void TheIdOfAnInsertionMustBeIndicatedInTheConstructorArgument()
 {
     var id = new Guid ("368e97a7-bafe-4b3f-9d4a-c49201ba026f");
     var @class = CreateInstance<IClass> ();
     var insertion =  new Screw.Framework.Services.Storage.Insertion(@class,id);
     Assert.AreEqual(id, insertion.Id);
 }
Пример #2
0
 public void IfFieldIsStringAndValueIsNotNullValueCanBeAnString()
 {
     var @class = CreateInstance<IClass>();
     var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
     var fieldMock = CreateMock<IField> ();
     fieldMock.StubGet (x => x.Class, @class);
     insertion.Set (fieldMock.MockObject, "a");
 }
Пример #3
0
 public void IfFieldIsStringAndValueIsNotNullValueCanNotBeNotString()
 {
     var @class = CreateInstance<IClass>();
     var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
     var fieldMock = CreateMock<ITextField> ();
     fieldMock.StubGet (x => x.Class, @class);
     var ex =Assert.Throws<ArgumentException>(() => insertion.Set (fieldMock.MockObject, new object()));
     Assert.AreEqual (ex.Message, "Text fields can only have values ​​of type string\nParameter name: value");
     Assert.AreEqual (ex.ParamName, "value");
 }
Пример #4
0
        public void TheFieldAndValueMustBeInInsertionBeforeSet()
        {
            var value = new object ();
            var @class = CreateInstance<IClass>();
            var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
            var fieldMock = CreateMock<IField> ();
            fieldMock.StubGet (x => x.Class, @class);
            insertion.Set (fieldMock.MockObject, value);

            var found = insertion.Values.Any (element => element.Key == fieldMock.MockObject && element.Value == value);
            Assert.IsTrue (found);
        }
Пример #5
0
        public void SetTwoTimesSameFieldMustFail()
        {
            var @class = CreateInstance<IClass> ();
            var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
            var fieldMock = CreateMock<IField> ();
            fieldMock.StubGet (x => x.Class, @class);
            insertion.Set (fieldMock.MockObject, new object());

            var ex = Assert.Throws<InvalidOperationException> (() => insertion.Set (fieldMock.MockObject, new object()));

            Assert.AreEqual ("The insertion already contains the specified field", ex.Message);
        }
Пример #6
0
        public void TheSettedFieldMustBeFromSameClassOfInsertion()
        {
            var @class = CreateInstance<IClass>();
            var otherClass = CreateInstance<IClass>();
            var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
            var fieldMock = CreateMock<IField> ();
            fieldMock.StubGet (x => x.Class, @otherClass);

            var ex = Assert.Throws<InvalidOperationException>(() =>  insertion.Set (fieldMock.MockObject, new object()));
            Assert.AreEqual ("The field does not belong to the class", ex.Message);
        }
Пример #7
0
 public void TheSettedFieldCanNotBeNull()
 {
     var @class = CreateInstance<IClass>();
     var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
     var ex = Assert.Throws<ArgumentNullException>(() =>  insertion.Set (null, new object()));
     Assert.AreEqual ("field", ex.ParamName);
 }
Пример #8
0
 public void TheClassOfAnInsertionMustBeIndicatedInTheConstructorArgument()
 {
     var @class = CreateInstance<IClass>();
     var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
     Assert.AreSame(@class, insertion.Class);
 }
Пример #9
0
 public void TheSettedValueCanBeNullIfFieldIsNullable()
 {
     var @class = CreateInstance<IClass>();
     var insertion =  new Screw.Framework.Services.Storage.Insertion(@class, Guid.Empty);
     var fieldMock = CreateMock<IField> ();
     fieldMock.StubGet (x => x.Nullable, false);
     fieldMock.StubGet (x => x.Class, @class);
     insertion.Set (fieldMock.MockObject, null);
 }