Exemplo n.º 1
0
        public void UserIdEmpty()
        {
            var service = new Core.Data.Model.UserService();

            var ex = Assert.Throws <ArgumentException>(() => new Core.Logic.UserServiceLogic().Save(service));

            Assert.Equal("user id most be specified to save a user service", ex.Message);
        }
Exemplo n.º 2
0
        public void Successful()
        {
            var service = new Core.Data.Model.UserService()
            {
                User_Id = Guid.NewGuid()
            };

            // mocks
            var userServicePersistor = Mocks.StrictMock <Core.Data.Persistor.UserService>();
            var bll = Mocks.StrictMock <Core.Logic.UserServiceLogic>(userServicePersistor);

            // record
            bll.Expect(b => b.Save(service)).CallOriginalMethod(OriginalCallOptions.NoExpectation);
            userServicePersistor.Expect(u => u.Save(service)).Return(service);
            userServicePersistor.Expect(u => u.Commit()).Return(1);

            Mocks.ReplayAll();
            var result = bll.Save(service);

            Assert.Equal(service.Id, result.Id);

            Mocks.VerifyAll();
        }
Exemplo n.º 3
0
        public void Successful()
        {
            // data
            var id      = Guid.NewGuid();
            var service = new Core.Data.Model.UserService()
            {
                Id = id
            };

            // mocks
            var userServicePersistor = Mocks.StrictMock <Core.Data.Persistor.UserService>();
            var bll = Mocks.StrictMock <Core.Logic.UserServiceLogic>(userServicePersistor);

            bll.Expect(b => b.Get(service.Id)).CallOriginalMethod(OriginalCallOptions.NoExpectation);
            userServicePersistor.Expect(d => d.Get(service.Id)).Return(service);

            // record
            Mocks.ReplayAll();

            var result = bll.Get(id);

            Assert.Equal(id, result.Id);
        }