Hi, I just downloaded project and get the following exception when attempting to run unit tests:
Project Type: ASP.NET CORE MVC & jQuery Project Version: v4.1.4 Framework: .NET Framework 4.6.1
Visual Studio: 15.2 ReSharper: 2017.1.2
Thoughts so far are that the sqlite3.dll included in the test project is the wrong version. Possibly for Core instead of full .NET framework?
5 Answer(s)
-
0
So it seems the reason I was getting the exception is because I was running the tests with ReSharper. It was using a x64 test runner which wasn't compatible with the sqlite3.dll (x86). I was able to run the tests with VS Test explorer without a problem. Changing the build configuration to x86 for the test project allowed me to run it with ReSharper. I am now, however, getting the following three failing tests:
Should_Get_Income_Statistics_Weekly_FirstDayOfWeek() Message: Shouldly.ShouldAssertException : output.IncomeStatistics.Count should be 3 but was 4
Should_Get_Income_Statistics_Weekly_NotFirstDayOfWeek() Message: Shouldly.ShouldAssertException : output.IncomeStatistics[1].Date should be 2017-05-08T00:00:00.0000000 but was 2017-05-07T00:00:00.0000000
Create_Language() Message: Shouldly.ShouldAssertException : currentLanguages.Any(l => l.Name == newLanguageName) should be True but was False
-
0
Same situation here, for the tests where income statistics are failing, i noticed its cos of the different cultures. Different cultures have different first day of the week, so i changed my test a bit to cater for that.
[Fact] public async Task Should_Get_Income_Statistics_Weekly_NotFirstDayOfWeek() { //Arrange UsingDbContext( context => { var standardEdition = context.SubscribableEditions.First(); context.SubscriptionPayments.Add(new SubscriptionPayment { Amount = 100, Status = SubscriptionPaymentStatus.Completed, EditionId = standardEdition.Id, CreationTime = new DateTime(2017, 5, 4) }); context.SubscriptionPayments.Add(new SubscriptionPayment { Amount = 200, Status = SubscriptionPaymentStatus.Completed, EditionId = standardEdition.Id, CreationTime = new DateTime(2017, 5, 11) }); context.SubscriptionPayments.Add(new SubscriptionPayment { Amount = 300, Status = SubscriptionPaymentStatus.Completed, EditionId = standardEdition.Id, CreationTime = new DateTime(2017, 5, 18) }); }); //Act var output = await _hostDashboardService.GetIncomeStatistics(new GetIncomeStatisticsDataInput { StartDate = new DateTime(2017, 5, 3), EndDate = new DateTime(2017, 5, 20), IncomeStatisticsDateInterval = ChartDateInterval.Weekly }); output.IncomeStatistics.Count.ShouldBe(3); output.IncomeStatistics[0].Amount.ShouldBe(100); output.IncomeStatistics[0].Date.ShouldBe(new DateTime(2017, 5, 3)); output.IncomeStatistics[1].Amount.ShouldBe(200); output.IncomeStatistics[1].Date.ShouldBeInRange(new DateTime(2017, 5, 7), new DateTime(2017, 5, 8)); output.IncomeStatistics[2].Amount.ShouldBe(300); output.IncomeStatistics[2].Date.ShouldBeInRange(new DateTime(2017, 5, 14), new DateTime(2017, 5, 15)); }
[Fact] public async Task Should_Get_Income_Statistics_Weekly_FirstDayOfWeek() { //Arrange UsingDbContext( context => { var standardEdition = context.SubscribableEditions.First(); context.SubscriptionPayments.Add(new SubscriptionPayment { Amount = 100, Status = SubscriptionPaymentStatus.Completed, EditionId = standardEdition.Id, CreationTime = new DateTime(2017, 4, 30) }); context.SubscriptionPayments.Add(new SubscriptionPayment { Amount = 200, Status = SubscriptionPaymentStatus.Completed, EditionId = standardEdition.Id, CreationTime = new DateTime(2017, 5, 10) }); context.SubscriptionPayments.Add(new SubscriptionPayment { Amount = 300, Status = SubscriptionPaymentStatus.Completed, EditionId = standardEdition.Id, CreationTime = new DateTime(2017, 5, 20) }); }); //Act var output = await _hostDashboardService.GetIncomeStatistics(new GetIncomeStatisticsDataInput { StartDate = new DateTime(2017, 4, 30), EndDate = new DateTime(2017, 5, 20), IncomeStatisticsDateInterval = ChartDateInterval.Weekly }); output.IncomeStatistics.Count.ShouldBe(3); output.IncomeStatistics[0].Amount.ShouldBe(100); output.IncomeStatistics[0].Date.ShouldBeInRange(new DateTime(2017, 4, 30), new DateTime(2017, 5, 1)); output.IncomeStatistics[1].Amount.ShouldBe(200); output.IncomeStatistics[1].Date.ShouldBeInRange(new DateTime(2017, 5, 7), new DateTime(2017, 5, 8)); output.IncomeStatistics[2].Amount.ShouldBe(300); output.IncomeStatistics[2].Date.ShouldBeInRange(new DateTime(2017, 5, 14), new DateTime(2017, 5, 15)); }
this is just a quick fix, not tested in other cultures tho, and I don't think it will work there. best way is to take current culture into consideration while arranging the tests data
The language test failing happened to me on my first time running too, but after awhile it went away, weird
-
0
Hi
Thanks for the information @soonjoo and @JasonG. I have created an issue about unit tests here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/323">https://github.com/aspnetzero/aspnet-ze ... issues/323</a>.
-
0
Thank you @ismcagdas, I will keep an eye on it.
-
0
Thanks for your feedback ;)