Exemple #1
0
        public void MemberTypeDefaultValueTest2()
        {
            var target = new MockDataModel();

            Assert.AreEqual(target.EntityMappings.FieldMappings["NullableDecimalValue"]
                            .DefaultValue, null);
        }
Exemple #2
0
        public void TargetInfoTest()
        {
            var target = new MockDataModel();

            Assert.AreEqual(target.EntityMappings.FieldMappings["StringValue"]
                            .ColumnName, "SV");
        }
Exemple #3
0
        public void TargetInfoTest2()
        {
            var target = new MockDataModel();

            Assert.AreEqual(target.EntityMappings.FieldMappings["StringValue"]
                            .TargetMemberType, typeof(string));
        }
        public void LoadDataModelTableMapping_DefaultTableNameTest()
        {
            var target = new MockDataModel();

            Assert.AreEqual("MockDataModel", target.EntityMappings.TableMapping.Table);
            Assert.AreEqual("dbo", target.EntityMappings.TableMapping.Schema);
        }
Exemple #5
0
        public void InnerDictionaryTest2()
        {
            var target = new MockDataModel();
            var value  = 3m;

            target.DecimalValue = value;
            Assert.AreEqual(value, target.DecimalValue);
        }
Exemple #6
0
        public void InnerDictionaryTest()
        {
            var target = new MockDataModel();
            var value  = "abc";

            target.StringValue = value;
            Assert.AreSame(value, target.StringValue);
        }
Exemple #7
0
        public void ToDataRowTest()
        {
            var target = new MockDataModel();

            target.StringValue = "abc";
            var dr = target.Convert.ToDataRow();

            Assert.AreEqual(dr["sv"], "abc");
        }
Exemple #8
0
        public async Task AddDataMutatorIsCalled()
        {
            // arrange
            var model = new MockDataModel();

            _dataMutator.Setup(x => x.BeforeAdd(model, _identity.Object));

            // act
            await _dataContext.Add(model, _identity.Object);

            // assert
            _dataMutator.Verify(x => x.BeforeAdd(model, _identity.Object), Times.Once);
        }
Exemple #9
0
        public async Task AddRecordIsSaved()
        {
            // arrange
            var model = new MockDataModel();

            _crudDataTools.Setup(x => x.AddModel(model));

            // act
            await _dataContext.Add(model, _identity.Object);

            // assert
            _crudDataTools.Verify(x => x.AddModel(model), Times.Once);
        }
Exemple #10
0
        public async Task AddChangeIsBroadcast()
        {
            // arrange
            var model = new MockDataModel();

            _changeTracker.Setup(x => x.BroadcastAdd(model, _identity.Object));

            // act
            await _dataContext.Add(model, _identity.Object);

            // assert
            _changeTracker.Verify(x => x.BroadcastAdd(model, _identity.Object), Times.Once);
        }
Exemple #11
0
        public void EqualsTest()
        {
            var targetA = new MockDataModel();

            targetA.StringValue  = "xx";
            targetA.DecimalValue = 3m;
            var targetB = new MockDataModel();

            targetB.StringValue  = "xx";
            targetB.DecimalValue = 3m;
            Assert.IsTrue(targetA.Equals(targetB));
            targetB.MarkDeleted = true;
            Assert.IsFalse(targetA.Equals(targetB));
        }
Exemple #12
0
        public async Task RemoveRecordIsSaved()
        {
            // arrange
            var oldState = new MockDataModel();
            var id       = Guid.NewGuid();

            _crudDataTools.Setup(x => x.GetModel <MockDataModel>(id)).Returns(Task.FromResult(oldState));
            _crudDataTools.Setup(x => x.RemoveModel <MockDataModel>(id));

            // act
            await _dataContext.Remove <MockDataModel>(id, _identity.Object);

            // assert
            _crudDataTools.Verify(x => x.GetModel <MockDataModel>(id), Times.Once);
        }
Exemple #13
0
        public async Task ModifyRecordIsSaved()
        {
            // arrange
            var oldState = new MockDataModel();
            var newState = new MockDataModel();

            _crudDataTools.Setup(x => x.GetModel <MockDataModel>(It.IsAny <Guid>())).Returns(Task.FromResult(oldState));
            _crudDataTools.Setup(x => x.ModifyModel(oldState, newState));

            // act
            await _dataContext.Modify(newState, _identity.Object);

            // assert
            _crudDataTools.Verify(x => x.ModifyModel(oldState, newState), Times.Once);
        }
Exemple #14
0
        public async Task RemoveChangeIsBroadcast()
        {
            // arrange
            var oldState = new MockDataModel();
            var id       = Guid.NewGuid();

            _crudDataTools.Setup(x => x.GetModel <MockDataModel>(id)).Returns(Task.FromResult(oldState));

            _changeTracker.Setup(x => x.BroadcastDelete(oldState, _identity.Object));

            // act
            await _dataContext.Remove <MockDataModel>(id, _identity.Object);

            // assert
            _changeTracker.Verify(x => x.BroadcastDelete(oldState, _identity.Object), Times.Once);
        }
Exemple #15
0
        public async Task ModifyChangeIsBroadcast()
        {
            // arrange
            var oldState = new MockDataModel();
            var newState = new MockDataModel();

            _crudDataTools.Setup(x => x.GetModel <MockDataModel>(It.IsAny <Guid>())).Returns(Task.FromResult(oldState));
            ;
            _changeTracker.Setup(x => x.BroadcastModify(oldState, newState, _identity.Object));

            // act
            await _dataContext.Modify(newState, _identity.Object);

            // assert
            _changeTracker.Verify(x => x.BroadcastModify(oldState, newState, _identity.Object), Times.Once);
        }
Exemple #16
0
        public void DataModelFieldMappingAttribute_DefaultNameTest()
        {
            var target = new MockDataModel();

            Assert.AreEqual(target.EntityMappings.FieldMappings["Field"].ColumnName, "Field");
        }