示例#1
0
        public void TestAddItemExecute()
        {
            // ARRANGE
            var businessEntityFactory          = new StarBusinessEntityFactory();
            IStarBusinessEntity businessEntity = businessEntityFactory.Create();

            var usecaseFactory = new AddItemUsecaseFactory(new IdClass());

            StarItemDto data = null;

            var returnInterface = new ItemCreated();

            returnInterface.Created += (s, e) =>
            {
                data = new StarItemDto
                {
                    Id       = e.Id,
                    IsNew    = e.IsNew,
                    ItemName = e.ItemName
                };
            };

            IAddStarItemInputPort addItemInterActor = usecaseFactory.Create(businessEntity);

            addItemInterActor.BindOutputBoundary(returnInterface);

            // ACT
            addItemInterActor.Execute();

            // ASSERT
            Assert.IsNotNull(data, "StarItemCreated return interface did not return data.");
            Assert.AreEqual(Guid.Parse(@"01234567-89ab-cdef-0000-0123456789AB"), data.Id);
            Assert.IsTrue(data.IsNew);
            Assert.AreEqual(String.Empty, data.ItemName);
        }
 public SaveItemInteractor(
     IStarRepositoryGateway entityGateway,
     IStarBusinessEntity starBl)
 {
     this.EntityGateway         = entityGateway;
     this.StarItemBusinessLogic = starBl;
     this.OutputBoundary        = new NoOutputBoundary();
 }
示例#3
0
 internal AddItemInteractor(
     IGenerateId idGenerator,
     IStarBusinessEntity starBl)
 {
     this.StarItemBusinessLogic = starBl;
     this.IdGenerator           = idGenerator;
     this.OutputBoundary        = new NoOutputBoundary();
 }
        public void TestCreateNewStarItem()
        {
            var factory            = new StarBusinessEntityFactory();
            IStarBusinessEntity be = factory.Create();
            var id = Guid.NewGuid();

            be.CreateNewStarItem(id);

            Assert.IsTrue(be.IsNew);
            Assert.AreEqual(id, be.Id);
            Assert.AreEqual(String.Empty, be.ItemName);
        }
示例#5
0
        public IAddStarItemInputPort Create(
            IStarBusinessEntity starBusinessEntity)
        {
            if (starBusinessEntity == null)
            {
                throw new ArgumentNullException(
                          nameof(starBusinessEntity),
                          $"{nameof(AddItemUsecaseFactory)}.{nameof(Create)} cannot take null as argument");
            }

            var addItemInteractor = new AddItemInteractor(
                this.IdGen,
                starBusinessEntity);

            return(addItemInteractor);
        }
示例#6
0
        public void TestCreate()
        {
            var businessEntityFactory          = new StarBusinessEntityFactory();
            IStarBusinessEntity businessEntity = businessEntityFactory.Create();

            var usecaseFactory = new AddItemUsecaseFactory(new IdClass());

            var outputBoundary = new Boundary();

            IAddStarItemInputPort addStarUseCase = usecaseFactory.Create(businessEntity);

            addStarUseCase.BindOutputBoundary(outputBoundary);

            addStarUseCase.Execute();

            Assert.IsTrue(outputBoundary.Triggered);
            Assert.IsTrue(outputBoundary.Data.IsNew);
        }
示例#7
0
 public ISaveStarItemInputPort Create(
     IStarBusinessEntity starBusinessEntity,
     IStarRepositoryGateway starRepositoryGateway)
 {
     return(new SaveItemInteractor(starRepositoryGateway, starBusinessEntity));
 }