Skip to content

ronTohar1/Workshop-Market

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Workshop-Market

In this project the server is implemented in C# whereas the client is implemented in type-script using react.

Running the server

  • Make sure you have installed:
  • Open the MarketBackend project via Visual Studio as an existing project
  • Config the server. See the next section for more details.
  • Open the Solution Explorer and right-click on the WebAPI project WebAPI project.
  • Now select "Set as Startup Project".
  • Click the "Run" button at the top of the screen.
  • After running the project, a browser page named "Swagger" should open automatically. You can ignore that.

Configure the server

For running the server using the WebAPI project, you must config an inital scenario for the market, including the admin's credentials.
First, go to Server/MarketBackend/MarketBackend/SystemSettings/App.config, and set ShouldRunInitFile = "True" and InitFilePath to path of scenario configuration file.
another configuration that you might want to check is ShouldUpdateDatabase. This is a flag for detaching the connection to the database. when off, the system will work without the persistence layer.

Scenario configuration file

This file should contain use cases for the system initialization.
The format is json with 2 fields for the admin's credentials, and third field for the use cases.
The loading process keeps results of the actions in variable environment that can be used later. In order to store use case's result, use the sub-field "Ret".
Please note that arguments for IDs are given as strings but parsed as a referene to var.
For example, the following initialization (Pseudo-Code):

OpenMarket("u0", "password0")         # admin id is always 0
id1 = Register("u1", "password1")   
Login("u1", "password1")
s1 = OpenNewMarket("id1", "store1")   # "id1" is reference to id1, "store1" is just a string

Should be written as:

{
  "AdminUsername": "u0",
  "AdminPassword": "password0",
  "UseCases": [
    {
      "Username": "u1",
      "Password": "password1",
      "Tag": "Register",
      "Ret": "id1"
    }, 
    {
      "Username": "u1",
      "Password": "password1",
      "Tag": "Login",
      "Ret": "_"
    },
    {
      "UserIdRef": "id1",
      "StoreName": "store1",
      "Tag": "OpenNewStore",
      "Ret": "s1"
    }
  ]
}

Running the client

It will be more comefortable to run the client from Visual Studio Code, but it's not mandatory.

  • Make sure you have installed:

  • Open a new terminal at market-client directory

  • Type "npm-install" or "npm i" and click enter. This will install all the dependencies for the project.

  • Now type "npm start" and press enter. A browser window should open with the url: http://localhost:3000/ (though it's possible that the port 3000 is already in use, in which case the terminal/CMD will ask you if it's ok to choose another port, but that doesn't really matter).

    • If npm cannot find react-google-charts package than try to: "npm install --save react-google-charts" and runnig with "npm start" again.
  • That's it! the client is running and kicking.

Notes:

  • To open a new client just enter the same root url in a new tab (usually: "http://localhost:3000/").
  • We recommend you run the server before running the client in order to avoid an unpleasant alerts.
  • Another problem that could pop up is that you don't have react installed in your workspace, in this case you can install react simply with npm install react@latest

Running the backend tests

  • In order to run the backend tests, the backend directory needs to be opened with Visual Studio, as explained earlier
  • Right-click the TestMarketBackend directory in the Solution Explorer and choose "Run Tests".
  • The Test Explorer window should open automatically and run the tests.