Our test is right now failing because we throw a not implemented exception here.
And instead of doing that, let's simply return a new array.
And instead of that array, we can create a new booking arm.
That's all we have to do.
Now let's start the test again.
So right click and I'll let me open up the test explorer to only start one because things are taking
a little bit too long now.
Let me just run one test and you will see that it will still fail.
So just give it a second.
You can see no members were found for comparison.
And the problem is that we have a new booking here, which is for sure completely empty.
Right.
We don't have anything inside here.
No members, no properties, not anything.
Right.
So and we need to adjust that so that we are really able to check for comparison, because in the end,
that's what will happen here.
Right?
So it should contain an equivalent of and for this call.
So it should contain something we need to make a comparison.
Is there something which is like that one here?
So let's add constructor and parameters to the booking DTO So simply scroll down and book DTO there
we go right down Ctrl to create a constructor, and inside of that constructor let's create a new Good,
which is a globally unique identifier which is just like an ID, but well, it contains the string.
And then we have string passenger email and in number of seats.
Okay.
Regarding that flight ID, if you are familiar with SQL databases, you know that most of the well entries
have a unique ID, a so called primary key, right?
So this is one of the main concepts of SQL or relational databases.
And this is what a good is also doing.
It's just a unique ID so that every flight has a completely unique ID.
Great.
So now when we book a flight, we create a new book.
DTO Right.
So if we're creating something, we will use the DTO for comparison and for fetching data and all of
that.
We will use the book read model.
I hope that's a little bit clearer now, but that's really not the point about that TDD course, right?
So even if you're not able to follow along with that DTO and that and whatever, please don't care too
much about it.
It's really like we are testing just another layer of our application.
But again, we are using all of the same rules and laws and all of that, but this time we're making
it a little bit more complex, but you will understand it more and more if you just follow along now
in this chapter.
So here we create a new book, DTO let's just assign some values here.
Let's say the flight ID to be a good new good.
That's very important.
Not only call new good, so don't do it like new good.
Right?
Because this will result in an invalid good.
Instead, call good dot new good.
There we go.
Our new good.
And then for passenger email we can set again, for example, a@b.com.
And then for number of seats we take two.
Great.
Okay, so this is all we have to do here.
Let me just bring that into the line of code.
Okay.
So we book something new, book DTO, and we submit some information here for the actual booking.
Let's do exactly the same thing for our booking right model that we have right here.
Read model.
Right.
So you can see for booking service, find bookings we check for contain equivalent of new booking and
that does not work as we have just discovered.
So what we do here is let's yeah, let's enter some data.
Passenger email for example, is then a@b.com and number of seats will be two.
Awesome.
So let's scroll down to our booking and also here add a constructor ctor tab tab.
And again we have like nearly the same information, but we don't have the flight ID, so string passenger
email and integer number of seats.
There we go.
And that should again give us a green state.
Here we have that new booking that for sure is no longer working because we don't have a matching constructor.
So for find bookings, let's just enter some fake data, a random string and 25, for example.
Now let's rerun our test and it should fail.
So test Explorer, right click.
Run.
Awesome.
So let me just show you the error here.
System invalid operation.
No members were found for comparison.
Please specify some members to include it in the comparison.
Okay.
So what we now have to do is to assign our booking model some properties.
Let's go into our booking model.
We got that right here.
Right now we have a constructor, but we have no properties, right?
So let's create two right down prop.
The first one is string passenger email and the second one prop is an integer for number of seats.
Now inside of the constructor we assign the values so passenger email equals to passenger email.
Make sure to to check that we for sure assign it in the correct way.
Let me just write that down here because passenger email is the property number of seats is the property.
And we assign the parameters here from the constructor, right?
So don't forget that or pay attention on that.
Okay, Let's save it.
Let's rerun the test.
So again, go to Test Explorer, right click on it and run.
Okay, So right now you can see a completely different error because he's trying to find an equivalent
of number of seats set to two and passenger email ab.com.
But he only has a booking model with number of seats set to 25 and passenger email to set well being
a random string.
So you can see this in the source code for sure.
We check for hey, do you have an ABC.com email and the number of seats set to two?
Right?
Such a booking model and no, we return find bookings.
We return the booking model array which contains one booking model email addresses set to random string
and 25.
So for sure, this test has to fail.
Now, if we want to make it work, we simply let's just take that new booking, let's just paste it
here that we create exactly the same booking model.
So here we check get that equivalent or do you have that equivalent of that booking model and now we
return it.
So that should work.
So right click or simply go to Test Explorer and test this test again.
And you can see that the test is now passing and that's nice.
So when I call book, the data should be stored into a database.
And when I call find bookings, the data should be fetched from there.
So let me just get that clear here.
We have book, right?
And right now we're only writing testing code, but that should store data inside of a database because
you book something.
All right?
And the database should know about that, right?
Oh, yeah.
Yeah.
He bought the Or he booked a flight.
And when we call, find bookings, that's fetching data.
So, hey, get me all of the bookings for Yannick, for example.
Right.
And then he will talk to database and database will return all of the bookings for Yannick.
So book is storing data and find bookings is fetching data.