コード例 #1
0
        public async Task Push_entity_pushed_changes_reset()
        {
            IDictionary <string, Tuple <string, object>[]> primaryKeys = new Dictionary <string, Tuple <string, object>[]>()
            {
                { ".", new Tuple <string, object>[] { new Tuple <string, object>("id", 1) } }
            };
            Mock <IDataAccessLayer> mockDal = new Mock <IDataAccessLayer>();

            mockDal.Setup(m => m.UpdateEntity(It.IsAny <Type>(), It.IsAny <string>(), It.IsAny <IEnumerable <string> >(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(primaryKeys));
            MockEntity entity = new MockEntity();

            entity.BeginEdit();
            entity.IntProperty = 1;
            string changesAsJson = entity.ChangesAsJson();

            await entity.PushAsync(mockDal.Object, 0, 1);

            mockDal.Verify(m => m.UpdateEntity(It.IsAny <Type>(), It.Is <string>(s => s.Equals(changesAsJson)), It.IsAny <IEnumerable <string> >(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()), Times.Once());
            Assert.AreEqual(0, entity.DbEntityChanges().Count());
        }