示例#1
0
 public void Setup()
 {
     options = new DbContextOptionsBuilder <AppDbContext>()
               .UseInMemoryDatabase(databaseName: "Add_writes_to_database").Options;
     context    = new AppDbContext(options);
     controller = new GoodController(context);
 }
示例#2
0
        public async Task Get_Returns_AFreshCake()
        {
            // Control over expected cake
            // Ignore internal logic/dependencies of any ICakeFactory Implementation
            var expectedCake = new Cake {
                Style = CakeStyle.ChocolateFudge, IsFresh = true
            };
            var cakeMock = Substitute.For <ICakeFactory>();

            cakeMock
            .Bake(0)
            .ReturnsForAnyArgs(expectedCake);

            var sut = new GoodController(cakeMock);

            var result = await sut.Get();

            var okObjectResult = result as OkObjectResult;

            Assert.NotNull(okObjectResult);

            var cake = okObjectResult.Value as Cake;

            Assert.NotNull(cake);

            Assert.True(cake.IsFresh);
        }
示例#3
0
        public AddGoodForm(GoodController controller)
        {
            this._controller = controller;

            InitializeComponent();

            this.btnAddGood.Click += this._controller.AddFromForm;
        }
示例#4
0
 public TripsModel(IStorage storage)
 {
     _trips = new TripController(storage);
     _photos = new PhotoController(storage);
     _places = new PlaceController(storage);
     _goals = new GoalController(storage);
     _goods = new GoodController(storage);
     _purchases = new PurchaseController(storage);
 }
示例#5
0
        public void SelfInit()
        {
            if (this._db == null)
            {
                this._db = new MyDatabase(new Config(Environment.CurrentDirectory));
            }

            this.SupplierDataController = new SupplierController(this, this._db);
            this.GoodDataController     = new GoodController(this, this._db);
            this.CategoryDataController = new CategoryController(this, this._db);

            this._initialized = true;
        }
示例#6
0
        private void _initForms()
        {
            this._supplierController = new SupplierController();
            this._categoryController = new CategoryController();
            this._goodController     = new GoodController();

            this.MainForm          = new MainForm(this);
            this.FirstSettingsForm = new FirstSettingsForm(this);

            this._supplierController.MainForm = this.MainForm;
            this._categoryController.MainForm = this.MainForm;
            this._goodController.MainForm     = this.MainForm;
        }