public void InstanceRepository_Create()
        {
            Domain.Instance instance = new Domain.Instance()
            {
                Closed = false,
                InstanceId = 0,
                InstanceName = "name",
                InstanceType = Domain.InstanceType.Build,
                Locked = false,
                Public = false
            };

            MockHolder<IUnitOfWork> uowHolder = new MockHolder<IUnitOfWork>(uow => { });

            MockUnitOfWorkFactory factory = new MockUnitOfWorkFactory(uowHolder.HoldAndSetup);
            factory.AddMockFunction<Domain.Instance>();

            IInstanceRepository repository = new InstanceRepository(factory.UnitOfWorkFactory, Utility.StandardMapper);

            Domain.Instance createdInstance = repository.Create(instance);

            Assert.IsNotNull(createdInstance);

            uowHolder.Verify(uow =>
            {
                uow.Verify(x => x.MarkNew(It.IsAny<Instance>()), Times.Once);
                uow.Verify(x => x.Commit(), Times.Once);
            });
        }
        public void InstanceRepository_Create_WithNull()
        {
            Domain.Instance instance = null;

            MockHolder<IUnitOfWork> uowHolder = new MockHolder<IUnitOfWork>(uow => { });

            MockUnitOfWorkFactory factory = new MockUnitOfWorkFactory(uowHolder.HoldAndSetup);
            factory.AddMockFunction<Domain.Instance>();

            IInstanceRepository repository = new InstanceRepository(factory.UnitOfWorkFactory, Utility.StandardMapper);

            repository.Create(instance);//throws exception
        }
        public void UserRepository_IsUser()
        {
            const string userId = "user";

            MockUnitOfWorkFactory unitOfWorkFactory = new MockUnitOfWorkFactory(uow => { });
            unitOfWorkFactory.AddMockFunction<bool>();

            IUserRepository repository = new UserRepository(unitOfWorkFactory.UnitOfWorkFactory, Utility.StandardMapper);

            bool result = repository.IsUser(userId);

            Assert.IsFalse(result);

            unitOfWorkFactory.MockUnitOfWork.Verify(x => x.Exists(It.IsAny<Expression<Func<AspNetUserRole, bool>>>()), Times.Once);
        }
        public void InstanceRepository_IsNameUnique_ForCreation()
        {
            const string instanceName = "name";
            int? instanceId = null;

            MockHolder<IUnitOfWork> uowHolder = new MockHolder<IUnitOfWork>(uow => { });

            MockUnitOfWorkFactory factory = new MockUnitOfWorkFactory(uowHolder.HoldAndSetup);
            factory.AddMockFunction<bool>();

            IInstanceRepository repository = new InstanceRepository(factory.UnitOfWorkFactory, Utility.StandardMapper);

            var result = repository.IsNameUnique(instanceName, instanceId);

            Assert.IsFalse(result);

            uowHolder.Verify(uow => {
                uow.Verify(x => x.Exists(It.IsAny<Expression<Func<Instance, bool>>>()), Times.Once);
            });
        }