public async Task ObservationQueryTest() { DatabaseSettingsConfig dbSettings = new DatabaseSettingsConfig() { ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename='E:\\MicroService CQRS\\MicroServicesCQRSDotNetCore\\Dot.Net.Infrastructure.Data\\Database\\PalindromeDB.mdf';Integrated Security=True;Connect Timeout=30" }; IOptions <DatabaseSettingsConfig> iDBSettings = Options.Create(dbSettings); IConnectToDatabase connection = new ConnectDB(iDBSettings); IObservationRepository observationRepository = new ObservationRepository(connection); var sut = new ObservationQueryHandler(observationRepository); var result = await sut.Handle(new ObservationQuery { Id = "CBX000001" }, CancellationToken.None); result.ShouldBeOfType <ObservationModel>(); result.Observations.ShouldNotBeNull(); }
public async Task CreateObservationQueryTest() { DatabaseSettingsConfig dbSettings = new DatabaseSettingsConfig() { ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename='E:\\MicroService CQRS\\MicroServicesCQRSDotNetCore\\Dot.Net.Infrastructure.Data\\Database\\PalindromeDB.mdf';Integrated Security=True;Connect Timeout=30" }; IOptions <DatabaseSettingsConfig> iDBSettings = Options.Create(dbSettings); IConnectToDatabase connection = new ConnectDB(iDBSettings); IObservationRepository observationRepository = new ObservationRepository(connection); var entity = new ObservationDTO { Id = 0, Discussion = "CQRS", DiscussionDate = DateTime.Now, DiscussionLocation = "Office", DiscussionWith = "Staff", Subject = "CQRS Pros vs Cons", Outcome = "Decided to go with CQRS", RecordedBy = "Hari", RecordedDate = DateTime.Now }; var sut = new CreateObservationCommandHandler(observationRepository); var result = await sut.Handle(new CreateObservationCommand { Id = 0, Discussion = "CQRS", DiscussionDate = DateTime.Now, DiscussionLocation = "Office", DiscussionWith = "Staff", Subject = "CQRS Pros vs Cons", Outcome = "Decided to go with CQRS", RecordedBy = "Hari", RecordedDate = DateTime.Now }, CancellationToken.None); result.ShouldBeOfType <bool>(); //result.ShouldBe(Unit); }