Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SEP-2024-team-D
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nahodil, Petr
SEP-2024-team-D
Commits
c5f466fe
Commit
c5f466fe
authored
3 months ago
by
Nahodil, Petr
Browse files
Options
Downloads
Patches
Plain Diff
fix of test generator (stop using DateTime.Now) and final fix of export.csv
parent
29c1bb11
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
FlightLogNet.Tests/export.csv
+4
-4
4 additions, 4 deletions
FlightLogNet.Tests/export.csv
FlightLogNet/TestDatabaseGenerator.cs
+107
-59
107 additions, 59 deletions
FlightLogNet/TestDatabaseGenerator.cs
with
111 additions
and
63 deletions
FlightLogNet.Tests/export.csv
+
4
−
4
View file @
c5f466fe
FlightID,TakeoffTime,LandingTime,Immatriculation,Type,Pilot,Copilot,Task,TowplaneID,GliderID
1,19.11.24 1
6:54:52
,,OK-V23428,Zlín Z-42M,Lenka Kiasová,,VLEK,,
4,19.11.24 1
6:54:52
,,OK-B128,L-13A Blaník,Silvie Hronová,,Tahac,2,2
1,19.11.24 1
7:06:47
,,OK-V23428,Zlín Z-42M,Lenka Kiasová,,VLEK,,
4,19.11.24 1
7:06:47
,,OK-B128,L-13A Blaník,Silvie Hronová,,Tahac,2,2
444,07.01.20 16:47:10,07.01.20 17:17:10,OK-B128,L-13A Blaník,Lenka Kiasová,,Tahac,2,2
24057,19.11.24 15:
24:52
,,OK-V23428,Zlín Z-42M,Petr Hrubec,,VLEK,,
24058,19.11.24 15:
24:52
,,OK-B128,L-13A Blaník,Silvie Hronová,,Tahac,2,2
24057,19.11.24 15:
36:47
,,OK-V23428,Zlín Z-42M,Petr Hrubec,,VLEK,,
24058,19.11.24 15:
36:47
,,OK-B128,L-13A Blaník,Silvie Hronová,,Tahac,2,2
This diff is collapsed.
Click to expand it.
FlightLogNet/TestDatabaseGenerator.cs
+
107
−
59
View file @
c5f466fe
...
...
@@ -2,11 +2,9 @@
{
using
System
;
using
System.Diagnostics
;
using
Models
;
using
Repositories
;
using
Repositories.Entities
;
using
Microsoft.Extensions.Configuration
;
internal
static
class
TestDatabaseGenerator
...
...
@@ -14,7 +12,7 @@
internal
static
void
RenewDatabase
(
IConfiguration
configuration
)
{
DeleteOldDatabase
(
configuration
);
CreateTestDatabaseWithFixedTime
(
DateTime
.
Now
,
configuration
);
CreateTestDatabaseWithFixedTime
(
new
DateTime
(
2024
,
11
,
19
,
17
,
16
,
47
,
DateTimeKind
.
Utc
)
,
configuration
);
}
public
static
void
DeleteOldDatabase
(
IConfiguration
configuration
)
...
...
@@ -26,8 +24,8 @@
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"ReSharper"
,
"StringLiteralTypo"
,
Justification
=
"This is test data."
)]
public
static
void
CreateTestDatabaseWithFixedTime
(
DateTime
now
,
IConfiguration
configuration
)
{
using
var
dbContext
=
new
LocalDatabaseContext
(
configuration
);
bool
newCreated
=
dbContext
.
Database
.
EnsureCreated
();
using
var
dbContext
=
new
LocalDatabaseContext
(
configuration
);
bool
newCreated
=
dbContext
.
Database
.
EnsureCreated
();
if
(!
newCreated
)
{
...
...
@@ -38,96 +36,145 @@
InitializeDatabase
(
configuration
);
dbContext
.
Persons
.
AddRange
(
new
Person
{
FirstName
=
"Kamila"
,
LastName
=
"Spoustová"
,
Address
=
null
},
new
Person
{
FirstName
=
"Naděžda"
,
LastName
=
"Pavelková"
,
Address
=
null
},
new
Person
{
FirstName
=
"Silvie"
,
LastName
=
"Hronová"
,
Address
=
null
,
Id
=
103
},
new
Person
{
FirstName
=
"Miloš"
,
LastName
=
"Korbel"
,
Address
=
null
},
new
Person
{
FirstName
=
"Petr"
,
LastName
=
"Hrubec"
,
Address
=
null
,
Id
=
105
},
new
Person
{
FirstName
=
"Michal"
,
LastName
=
"Vyvlečka"
,
Address
=
null
},
new
Person
{
Id
=
112
,
FirstName
=
"Kamila"
,
LastName
=
"Spoustová"
,
Address
=
null
},
new
Person
{
FirstName
=
"Naděžda"
,
LastName
=
"Pavelková"
,
Address
=
null
},
new
Person
{
FirstName
=
"Silvie"
,
LastName
=
"Hronová"
,
Address
=
null
,
Id
=
103
},
new
Person
{
FirstName
=
"Miloš"
,
LastName
=
"Korbel"
,
Address
=
null
},
new
Person
{
FirstName
=
"Petr"
,
LastName
=
"Hrubec"
,
Address
=
null
,
Id
=
105
},
new
Person
{
FirstName
=
"Michal"
,
LastName
=
"Vyvlečka"
,
Address
=
null
},
new
Person
{
Id
=
112
,
FirstName
=
"Lenka"
,
LastName
=
"Kiasová"
,
Address
=
new
Address
{
City
=
null
,
Country
=
null
,
PostalCode
=
null
,
Street
=
null
}
});
LastName
=
"Kiasová"
,
Address
=
new
Address
{
City
=
null
,
Country
=
null
,
PostalCode
=
null
,
Street
=
null
}
}
);
dbContext
.
Airplanes
.
AddRange
(
new
Airplane
{
Id
=
2
,
GuestAirplaneImmatriculation
=
"OK-B128"
,
GuestAirplaneType
=
"L-13A Blaník"
},
new
Airplane
{
Id
=
1
,
GuestAirplaneImmatriculation
=
"OK-V23428"
,
GuestAirplaneType
=
"Zlín Z-42M"
});
new
Airplane
{
Id
=
2
,
GuestAirplaneImmatriculation
=
"OK-B128"
,
GuestAirplaneType
=
"L-13A Blaník"
},
new
Airplane
{
Id
=
1
,
GuestAirplaneImmatriculation
=
"OK-V23428"
,
GuestAirplaneType
=
"Zlín Z-42M"
}
);
dbContext
.
Flights
.
AddRange
(
new
Flight
{
Id
=
1
,
Id
=
1
,
TakeoffTime
=
now
.
AddMinutes
(-
10
),
LandingTime
=
null
,
Airplane
=
dbContext
.
Airplanes
.
Find
(
1L
),
Pilot
=
dbContext
.
Persons
.
Find
(
112L
),
Copilot
=
null
,
Task
=
"VLEK"
,
Type
=
FlightType
.
Glider
Airplane
=
dbContext
.
Airplanes
.
Find
(
1L
),
Pilot
=
dbContext
.
Persons
.
Find
(
112L
),
Copilot
=
null
,
Task
=
"VLEK"
,
Type
=
FlightType
.
Glider
},
new
Flight
{
Id
=
4
,
Id
=
4
,
TakeoffTime
=
now
.
AddMinutes
(-
10
),
LandingTime
=
null
,
Airplane
=
dbContext
.
Airplanes
.
Find
(
2L
),
Pilot
=
dbContext
.
Persons
.
Find
(
103L
),
Copilot
=
null
,
Task
=
"Tahac"
,
Type
=
FlightType
.
Towplane
Airplane
=
dbContext
.
Airplanes
.
Find
(
2L
),
Pilot
=
dbContext
.
Persons
.
Find
(
103L
),
Copilot
=
null
,
Task
=
"Tahac"
,
Type
=
FlightType
.
Towplane
},
new
Flight
{
Id
=
24057
,
Id
=
24057
,
TakeoffTime
=
now
.
AddMinutes
(-
100
),
LandingTime
=
null
,
Airplane
=
dbContext
.
Airplanes
.
Find
(
1L
),
Pilot
=
dbContext
.
Persons
.
Find
(
105L
),
Copilot
=
null
,
Task
=
"VLEK"
,
Type
=
FlightType
.
Glider
Airplane
=
dbContext
.
Airplanes
.
Find
(
1L
),
Pilot
=
dbContext
.
Persons
.
Find
(
105L
),
Copilot
=
null
,
Task
=
"VLEK"
,
Type
=
FlightType
.
Glider
},
new
Flight
{
Id
=
24058
,
Id
=
24058
,
TakeoffTime
=
now
.
AddMinutes
(-
100
),
LandingTime
=
null
,
Airplane
=
dbContext
.
Airplanes
.
Find
(
2L
),
Pilot
=
dbContext
.
Persons
.
Find
(
103L
),
Copilot
=
null
,
Task
=
"Tahac"
,
Type
=
FlightType
.
Towplane
Airplane
=
dbContext
.
Airplanes
.
Find
(
2L
),
Pilot
=
dbContext
.
Persons
.
Find
(
103L
),
Copilot
=
null
,
Task
=
"Tahac"
,
Type
=
FlightType
.
Towplane
},
new
Flight
{
Id
=
444
,
Id
=
444
,
TakeoffTime
=
new
DateTime
(
2020
,
1
,
7
,
16
,
47
,
10
),
LandingTime
=
new
DateTime
(
2020
,
1
,
7
,
17
,
17
,
10
),
Airplane
=
dbContext
.
Airplanes
.
Find
(
2L
),
Pilot
=
dbContext
.
Persons
.
Find
(
112L
),
Copilot
=
null
,
Task
=
"Tahac"
,
Type
=
FlightType
.
Towplane
});
Airplane
=
dbContext
.
Airplanes
.
Find
(
2L
),
Pilot
=
dbContext
.
Persons
.
Find
(
112L
),
Copilot
=
null
,
Task
=
"Tahac"
,
Type
=
FlightType
.
Towplane
}
);
dbContext
.
FlightStarts
.
AddRange
(
new
FlightStart
{
Glider
=
dbContext
.
Flights
.
Find
(
1L
),
Glider
=
dbContext
.
Flights
.
Find
(
1L
),
Towplane
=
dbContext
.
Flights
.
Find
(
4L
)
},
new
FlightStart
{
Glider
=
dbContext
.
Flights
.
Find
(
24057L
),
Glider
=
dbContext
.
Flights
.
Find
(
24057L
),
Towplane
=
dbContext
.
Flights
.
Find
(
24058L
)
},
new
FlightStart
{
Towplane
=
dbContext
.
Flights
.
Find
(
444L
)
});
new
FlightStart
{
Towplane
=
dbContext
.
Flights
.
Find
(
444L
)
}
);
dbContext
.
SaveChanges
();
}
...
...
@@ -139,16 +186,17 @@
dbContext
.
ClubAirplanes
.
AddRange
(
new
ClubAirplane
{
Id
=
2
,
Id
=
2
,
Immatriculation
=
"OK-B123"
,
AirplaneType
=
new
AirplaneType
{
Type
=
"L-13A Blaník"
}
AirplaneType
=
new
AirplaneType
{
Type
=
"L-13A Blaník"
}
},
new
ClubAirplane
{
Id
=
1
,
Id
=
1
,
Immatriculation
=
"OK-V23424"
,
AirplaneType
=
new
AirplaneType
{
Type
=
"Zlín Z-42M"
}
});
AirplaneType
=
new
AirplaneType
{
Type
=
"Zlín Z-42M"
}
}
);
dbContext
.
SaveChanges
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment