示例#1
0
        public async Task ReadHandler_Pagination()
        {
            var logger = new Mock <ILogger <AuditHandler> >();
            var sp     = MockServiceProvider(logger);
            var am     = new Mock <IAuditManager>();

            sp.Setup(s => s.GetService(typeof(IAuditManager))).Returns(am.Object);
            var h = new AuditHandler(sp.Object);

            var o = new Pagination <string>
            {
                Data = new[] { "1", "2", "3" }
            };

            var uId = "u-id";
            var wc  = new WorkContext {
                CurrentUserId = uId
            };

            var ded = new DomainEvent
            {
                Data = o,
                PerformedByUserId = uId,
                WorkContext       = wc
            };
            await h.ReadEventHandler(ded);

            am.Verify(a => a.InsertAuditRecord(
                          It.Is <Type>(t => t == typeof(string)),
                          It.Is <string>(i => i == null),
                          It.Is <string>(art => art == AuditRecordTypes.READ),
                          It.Is <WorkContext>(w => w == wc),
                          It.Is <object>(obj => obj.GetPropertyValueByName <IEnumerable <string> >("Data") == o.Data)),
                      Times.Once);
        }
示例#2
0
        public async Task ReadHandler()
        {
            var logger = new Mock <ILogger <AuditHandler> >();
            var sp     = MockServiceProvider(logger);
            var am     = new Mock <IAuditManager>();

            sp.Setup(s => s.GetService(typeof(IAuditManager))).Returns(am.Object);
            var h = new AuditHandler(sp.Object);

            var o = new EventDataObject
            {
                Id    = "123",
                Value = "data"
            };

            var uId = "u-id";
            var wc  = new WorkContext {
                CurrentUserId = uId
            };

            var ded = new DomainEvent
            {
                Data = o,
                PerformedByUserId = uId,
                WorkContext       = wc
            };
            await h.ReadEventHandler(ded);

            am.Verify(a => a.InsertAuditRecord(
                          It.Is <Type>(t => t == typeof(EventDataObject)),
                          It.Is <string>(i => i == o.Id),
                          It.Is <string>(art => art == AuditRecordTypes.READ),
                          It.Is <WorkContext>(w => w == wc),
                          It.Is <object>(obj => obj == o)),
                      Times.Once);
        }