Fitnesse - method name starting with unwanted "set" prefix - c#

I have trouble with fitnesse adding a prefix "set" to names of my methods and therefore not finding any. It does not do the same thing with a different method from same, which I figured is because said method starts with "get" so I guess there is something I am missing in the syntax since this keyword makes it act differently.
Fitnesse code:
!define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,C:\Users\Kain\Source\repos\mc\build\Tools\fitnesse\fitSharp.dll %p}
!define TEST_RUNNER {C:\Users\Kain\Source\repos\mc\build\Tools\fitnesse\RunnerW.exe}
!define TEST_SYSTEM {slim}
!path ..\..\results\WindowsHost\Acceptance.Tests.dll
!|Namespace.ConnectorClass|
| get connector schemas |
| ensure | has input schema defined |
| ensure | has output schema defined |
!|Namespace.ConnectorClass|
| send valid query |
| ensure | is valid input |
| ensure | is valid response |
| reject | is error response |
| show | error |
Output:

It looks like you are trying to use the Slim script table. So you need to put script in the first cell of your table:
!|script|Namespace.ConnectorClass|
| get connector schemas |
| ensure | has input schema defined |
| ensure | has output schema defined |
See http://fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.ScriptTable
Without the script cell, Slim is treating your table as a Slim decision table.

Related

Unique constraint for values in different column

I have a table that has a key and an alternative key column within the same table. If a value is set in the key column, it must not be used in the alternative key column and vice versa. `
For example, this should be valid:
-----------------------------
| Key | alternative Key |
|---------|-----------------|
| Key_1 | NULL |
| Key_2 | NULL |
| Key_3 | Key_36 |
| Key_4 | NULL |
| ... | ... |
-----------------------------
But this should not be allowed:
-----------------------------
| Key | alternative Key |
|---------|-----------------|
| Key_1 | NULL |
| Key_2 | NULL |
| Key_3 | Key_1 |
| Key_4 | NULL |
| ... | ... |
-----------------------------
The root of the problem is, that my system communicates with a PLC through these keys. However, there are some use-cases where the key we send to the PLC is different from the key we display on screen. The key is always displayed on screen, but if an alternative key is present, it is used for communication instead of the key.
Is it possible to prevent this using SQL constraints or do I need to handle this in my business logic? I am using a code-first approach with C# entities using entity framework core, if that makes a difference. I don't want to change my data-model, if I don't have to.
I agree 100% with the above comments about correcting your data model. Some databases, e.g., Sql Server, support unique indexes on schema-bound views. A view like Select Key From TheTable Union All Select AlternateKey From TheTable Where AlternateKey Is Not Null could then enforce a unique constraint.

How can I store data from a webapi like a DbContext DbSet in ASP.NET MVC?

I just followed this tutorial on loading json from a WebAPI into MVC: https://www.c-sharpcorner.com/article/consuming-asp-net-web-api-rest-service-in-asp-net-mvc-using-http-client/
This all worked, but it only displays the data in the index page.
Im also using a DbContext for loading data directly from a database. The advantage of DbContexts is that the data gets stored in a DbSet which I can call at any time to get data.
I would like the same for the WebAPI data.
I have 2 endpoints containing information from 2 tables.
Items
-----------------------------------------------
| Id | Name | Material |
-----------------------------------------------
| 1004 | Chain | Gold |
| 1402 | Vase | Ceramic |
-----------------------------------------------
Retailers
-----------------------------------------------
| Id | Name | City |
-----------------------------------------------
| 3829 | StoreA | New York |
| 1827 | StoreB | London |
-----------------------------------------------
I can retrieve the information with /api/items and /api/retailers.
I currently have a DbContext for the other data, who use repositories to link the data from the DbContext to the Views.

Creating a Pivot table in C#

In my c# program I have someone input production for the whole day and I calculate machine usage (MU) like so:
Date | Part Number | Mold Num | Machine Num | MU
2/12/2016 | 1185-5B8 | 6580 | 12 | .428
2/12/2016 | 2249300 | 7797 | 36 | .271
2/12/2016 | 146865 | 5096789 | 12 | .260
2/16/2016 | 123456 | 7787 | 56 | .354
2/16/2016 | 123456 | 787 | 54 | .45
2/16/2016 | 123456 | 777 | 56 | .799
2/16/2016 | 123456 | 87 | 54 | .611
All of this data is in my SQL server and what I want to do is to make something like a pivot table and it takes all similar dates/Mold Numbers/Machine Numbers and makes an average the MU and display it in any way that the user wants. Example:
Date | MU
2/12/2016 | 32.0%
2/16/2016 | 55.4%
or
Machine Num. | MU
12 | 34.4%
36 | 27.1%
54 | 53.0%
56 | 57.6%
etc. Basically I want it to be variable and to show whatever the person that is looking at it needs. I want to keep it in my c# program but I can use LINQ to SQL. Please keep in mind that I am very new to c# and LINQ to SQL.
I did try to do this but it was not exactly what I wanted to do. I also could not figure out how I was going to display it on the windows form nor how to change what was in each column.
It seems you need to build pivot table with row dimension (Date, Machine Num), without column dimension and with average by MU.
You can easily do that with help of NReco PivotData library:
var pivotData = new PivotData(
new string[] {"Date","Machine Num"},
new AverageAggregatorFactory("MU"),
new DataTableReader(t) ); // just a sample - you can use DB data reader
var pivotTable = new PivotTable(
new []{"Date"}, // row dimension(s)
new [0], // column dimension(s)
pivotData );
// use pivotTable.RowKeys and indexer for accessing pivot table values
PivotData library can be used for free (I'm an author), and you can download examples package on the component's page. Also you may check advanced PivotData Toolkit components (for rendering pivot table to HTML/CSV/Excel/PDF, aggregating data on DB level with GROUP BY and many others), but they are not free.
According to your description, what you want isn't a pivot table, as already mentioned by #juharr.
For sqlite, this sould be accomplished with the following statement. (I assume the table name is tmp, and what you want is the sum of MU with each MachineNUm, naming it with SMU).
SELECT MachineNum,SUM(MU) AS SMU From tmp GROUP BY MachineNum ORDER BY MachineNum;
Hope it helps.

Comparing Multiple Tables

There is a horrible legacy tool at my workplace that has been updated/patched to output information to an SQLite database. No one wants to touch the back end of the system, and I don't know enough to dig into it - not my problem. Here is my problem however:
I have an SQLite database, with a number of tables in it. Each table represents a day and contains all of the bus runs, listed such as such:
| Direction | Time | RunNumber | StopIndex |
----------------------------------------------
| In | 6:30 | 1 | 1 |
| In | 6:35 | 1 | 2 |
| In | 6:40 | 1 | 3 |
| In | 6:45 | 1 | 4 |
| In | 7:30 | 2 | 1 |
| In | 7:35 | 2 | 2 |
| In | 7:40 | 2 | 3 |
| In | 7:45 | 2 | 4 |
| Out | 6:40 | 1 | 1 |
| Out | 6:45 | 1 | 2 |
| Out | 6:50 | 1 | 3 |
| Out | 6:55 | 1 | 4 |
Some days can have more run's than others. The numbers of stops will be the same across all tables.
The definition of equal is that both direction and time are the same. Each run is treated as a set - if one of the times for a stop differs, then the entire run needs to be merged into a table.
My question is:
What would be the easiest way, given a list of tables, to generate another table that contains values that were not present on all the given tables? This can be done on the SQLite side, or by C# .NET 4.0.
In reality, I only need to know the run number that differs, so I can later extract it and put it into an Excel Spreadsheet, if that makes it any easier.
Try using EXCEPT. For example, the following query will list all rows that exist in Table1 but do not exist in Table2:
SELECT Direction, Time, RunNumber, StopIndex
FROM Table1
EXCEPT
SELECT Direction, Time, RunNumber, StopIndex
FROM Table2

Generating pdf using itextsharp in asp.net c#

I want to generate pdf file as attached in the picture. i want to harcode the contents shown in the picture into a pdf file on button click.
How do i proceed, using table structure will work?I am unable to form the table stucture here.
Please help me to sort out my problem.i want the output as shown in below image.
Here you have a good tutorial about using iTextSharp
http://www.mikesdotnetting.com/Category/20
First create one table with two columns like below
_______________________________________________
| | |
| | |
| | |
| COL.0.1 | COL.0.2 |
| | |
| | |
-----------------------------------------------
keep reference to its columns, then create table for left side content and insert it as child content of left column COL.0.1
------------------------------
| designation: xxxxxxx | <---- colspan = 2
------------------------------
| Audit No. | xxxx |
------------------------------
| Received on ....... |
-------------------------------
and you can continue for the rest of content similar to this.
The idea is to split content to smaller tables and nest them.

Categories

Resources