コード例 #1
0
        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);
            });
        }
コード例 #2
0
        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
        }