public void CanLoadAllWareGroups()
 {
     var dao = new Mock<IDao<WareGroup>>();
     var entityFactory = new Mock<IEntityFactory>();
     entityFactory.Setup(ent => ent.Create<WareGroup>()).Returns(new WareGroup()).AtMostOnce();
     var createWareGroupModel = new WareGroupModel(dao.Object, entityFactory.Object, new Mock<IEntityValidator>().Object);
     var wareGroup = createWareGroupModel.GetAllWareGroups();
     dao.Verify(d => d.RetrieveAll());
 }
 public void CanCancelWareGroup()
 {
     var dao = new Mock<IDao<WareGroup>>();
     var entityFactory = new Mock<IEntityFactory>();
     var wareGroup = new WareGroup();
     dao.Setup(rep => rep.Refresh(It.IsAny<WareGroup>())).AtMostOnce();
     var createWareGroupModel = new WareGroupModel(dao.Object, entityFactory.Object,
                                                   new Mock<IEntityValidator>().Object);
     createWareGroupModel.CancelWareGroup(wareGroup);
     dao.Verify(daowareGroup => daowareGroup.Refresh(wareGroup));
 }
        public void SaveWareGroupShouldDoesntWorkIfWareGroupInvalid()
        {
            var repository = new Mock<IDao<WareGroup>>();
            var entityValidator = new Mock<IEntityValidator>();
            var entityFactory = new Mock<IEntityFactory>();

            var wareGroup = new WareGroup();

            entityValidator.Setup(ev => ev.IsValid(wareGroup)).Returns(false);

            var albumManagerModel = new WareGroupModel(repository.Object,
                                                          entityFactory.Object,
                                                          entityValidator.Object);

            albumManagerModel.SaveWareGroup(wareGroup);

            entityValidator.Verify(ev => ev.IsValid(wareGroup));
        }
        public void SaveWareGroupShouldWork()
        {
            var repository = new Mock<IDao<WareGroup>>();
            var entityValidator = new Mock<IEntityValidator>();
            var entityFactory = new Mock<IEntityFactory>();
            var wareGroup = new WareGroup();

            entityValidator.Setup(ev => ev.IsValid(wareGroup)).Returns(true);
            repository.Setup(rep => rep.Save(It.IsAny<WareGroup>())).AtMostOnce();

            var albumManagerModel = new WareGroupModel(repository.Object,
                                                          entityFactory.Object,
                                                          entityValidator.Object);

            albumManagerModel.SaveWareGroup(wareGroup);

            entityValidator.Verify(ev => ev.IsValid(wareGroup));
            repository.Verify(rep => rep.Save(wareGroup));
        }