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 void TestCreateArgumentNull() { var factory = new AddItemUsecaseFactory(new IdClass()); IAddStarItemInputPort addStarItem = factory.Create(null); addStarItem.Execute(); }
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); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // ============================== // build the overview window. // ============================== // 1) create the factories and their created classes. var factory1 = new StarBusinessEntityFactory(); var starBusinessEntity = factory1.Create(); var factory2 = new AddItemUsecaseFactory(new IdGeneratorClass()); var addItemInteractor = factory2.Create(starBusinessEntity); var gatewayFactory = new StarRepositoryGatewaySqlServerFactory(); var gateway = gatewayFactory.CreateSqlServer(); var saveItemUsecaseFactory = new SaveItemFactory(); var saveItemInteractor = saveItemUsecaseFactory.Create(starBusinessEntity, gateway); // 2 create the controller IStarOverviewController controller = new StarOverviewController(addItemInteractor, saveItemInteractor); // 2 create the viewmodel var viewModel = new StarOverviewViewModel(controller); // 3) create the presenter var presenter = new StarOverviewPresenter(viewModel); addItemInteractor.BindOutputBoundary(presenter); saveItemInteractor.BindOutputBoundary(presenter); var view = new MainWindow { DataContext = viewModel }; view.Show(); }