Base solution for your next web application

Activities of "justinp"

Thanks, and I do see what you are saying. If I'm returning a Dto, it should be checked against a Dto. In fact, I don't care as long as the collection isn't empty.

//Act
ListResultDto<PatientListDto> patients = _patientAppService.GetPatients(new GetPatientInput());

//Assert
patients.Items.Count.ShouldBeGreaterThan(0);

Message: System.IO.FileNotFoundException : Could not load the specified file.

Hello,

I have built a new app service that I intend for the tenants to use to create a new object. I have also seeded the database for the default tenant with several objects to test and ensure the service. However, when I write a test, I get an error and the test fails.

Message: System.InvalidOperationException : Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.

Since this is a template, what is the procedure for testing tenant services?

I've disabled the test on line 67 and it passed.

// currentLanguages.Count(l => l.Name == newLanguageName).ShouldBe(1);

What is it about this line that will fail?

Running a simple update to 4.1.3 Angular + Core. My first step is to download 4.1.3 and get it running in Azure, then we move our changes over once it is verified to run.

We've created a new database in Azure and run Update-Database EF command against it.

Our build fails during the tests on the Create_Language test. Is there a reason this would succeed locally, then fail when deployed?

Here's the test:

[Fact]
        public async Task Create_Language()
        {
            //Act
            var output = await _languageAppService.GetLanguageForEdit(new NullableIdDto(null));

            //Assert
            output.Language.Id.ShouldBeNull();
            output.LanguageNames.Count.ShouldBeGreaterThan(0);
            output.Flags.Count.ShouldBeGreaterThan(0);

            //Arrange
            var currentLanguages = await _languageManager.GetLanguagesAsync(AbpSession.TenantId);
            var nonRegisteredLanguages = output.LanguageNames.Where(l => currentLanguages.All(cl => cl.Name != l.Value)).ToList();

            //Act
            var newLanguageName = nonRegisteredLanguages[RandomHelper.GetRandom(nonRegisteredLanguages.Count)].Value;
            await _languageAppService.CreateOrUpdateLanguage(
                new CreateOrUpdateLanguageInput
                {
                    Language = new ApplicationLanguageEditDto
                    {
                        Icon = output.Flags[RandomHelper.GetRandom(output.Flags.Count)].Value,
                        Name = newLanguageName
                    }
                });

            //Assert
            currentLanguages = await _languageManager.GetLanguagesAsync(AbpSession.TenantId);
            currentLanguages.Count(l => l.Name == newLanguageName).ShouldBe(1);
        }

Here's the error:

2017-08-13T18:46:40.7656928Z Failed   Company.Project.Tests.Localization.LanguageAppService_Tests.Create_Language
2017-08-13T18:46:40.7656928Z Error Message:
2017-08-13T18:46:40.7656928Z  Shouldly.ShouldAssertException : 0
2017-08-13T18:46:40.7656928Z     should be
2017-08-13T18:46:40.7656928Z 1
2017-08-13T18:46:40.7656928Z     but was not
2017-08-13T18:46:40.7656928Z Stack Trace:
2017-08-13T18:46:40.7656928Z    at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
2017-08-13T18:46:40.7656928Z    at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected, Func`1 customMessage)
2017-08-13T18:46:40.7656928Z    at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected)
2017-08-13T18:46:40.7656928Z    at Akesotek.Apollo.Tests.Localization.LanguageAppService_Tests.&lt;Create_Language&gt;d__4.MoveNext() in d:\a\1\s\test\Akesotek.Apollo.Tests\Localization\LanguageAppService_Tests.cs:line 67
2017-08-13T18:46:40.7656928Z --- End of stack trace from previous location where exception was thrown ---
2017-08-13T18:46:40.7656928Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2017-08-13T18:46:40.7656928Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2017-08-13T18:46:40.7656928Z --- End of stack trace from previous location where exception was thrown ---
2017-08-13T18:46:40.7656928Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2017-08-13T18:46:40.7656928Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2017-08-13T18:46:40.7656928Z --- End of stack trace from previous location where exception was thrown ---
2017-08-13T18:46:40.7656928Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2017-08-13T18:46:40.7656928Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2017-08-13T18:47:21.8278038Z [xUnit.net 00:02:10.0703411]   Finished:    Company.Project.Tests

Thanks. Perhaps they can post the fix here if it's known (or anyone that's looked into it and has a solution). Since there is no real upgrade path (they refer to it as a "template" or "pattern"), I'd prefer not to have to port my entire solution to 4.2 when it is available just to fix such a small bug.

Hello,

I've downloaded 4.1 and the left side menue doesn't collapse when you click the "hamburger". I have testers on tablets and used multiple browsers (chrome, edge(!), ie and firefox).

Thanks,

Justin

Thank you. Returning a string appears to have been my issue. ABP tries to cast as an AjaxResponse and a simple "string" does not work, however a boolean does. Good to know.

Also, knowing where to look is helpful :lol:

For other's information, as ismcagdas mentioned [project].Web.Host\App_Data\Logs\Logs.txt:

ERROR 2017-07-02 23:25:15,358 [30   ] Microsoft.AspNetCore.Server.Kestrel      - Connection id "0HL61PCSP9TUI": An unhandled exception was thrown by the application. System.InvalidCastException: Unable to cast object of type 'Abp.Web.Models.AjaxResponse' to type 'System.String'.

I am incredibly frustrated in trying to sort out why the issue with not being able to create new services and getting what appeared to be a CORS issue (#3448).

I have lost a week on this issue and posted and emailed my code. I finally gave up and loaded 4.1 to start over by hand to try and get something working.

The first thing I did was add a new service interface and service. All it does is accept a string and return that same string:

public interface IConnectionAppService : IApplicationService
    {
        string TestConnection(string input);
    }

public class ConnectionsAppService : ApolloAppServiceBase, IConnectionAppService
    {
        public string TestConnection(string input)
        {
            return input;
        }
    }

Then I ran the service and updated the Angular service-proxies (refresh.bat). Finally, I created a simple component that ngOnInit calls the service. created a "Connections" page under the "app\admin" and added my component routing and module to the admin.module.ts and admin-routing.module.ts. Here's the component code:

import { Component, Injector, OnInit } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { ConnectionsServiceProxy } from '@shared/service-proxies/service-proxies';

@Component({
    templateUrl: './connection-manager.component.html',
    animations: [appModuleAnimation()],
    providers: [ConnectionsServiceProxy]
})

export class ConnectionManagerComponent extends AppComponentBase implements OnInit {

    private resultString: string;

    constructor(
        injector: Injector,
        private _ConnectionsService: ConnectionsServiceProxy
    ) {
        super(injector);
    }

    ngOnInit(): void {
        this._ConnectionsService.testConnection("Testing from API.").subscribe(
            (result) => { this.resultString = result; },
            (result) => { this.resultString = result; },
            () => { }
        );
    }

}

I am still seeing the same error UI popup, and 500 error, even though my code executes without throwing an error on the Server side.

XMLHttpRequest cannot load http://localhost:22742/api/services/app/Connections/TestConnection?input=Testing%20from%20API.. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

Can someone take a look at this or the code I sent in (shared via Google Drive).

Thanks in advance,

Justin

Is the public website in 4.1 a mistake or is this implemented intentionally? Is there any guidance on using the public website, or is it the same as other project types (MVC+jQuery)?

I looked for the missing file in the original download, but that didn't help. Then I copied the Host project out of the ZIP download file over mine, reset the startup project and database connection string, and re-ran Update-Database. It worked. I'm leaving this here in case someone else gets the error.

Showing 1 to 10 of 79 entries