小编Si *_*Thu的帖子

Angular 2 Unit Test:自定义管道错误找不到管道

我有一个名为'myPipe'的自定义管道.我收到管道'myPipe'在我的单元测试ts中找不到错误.

请求在我的.spec.ts中建议导入和声明的内容

这是我的.spec.ts

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';

import { MyComponent } from './main-page-carousel.component';

describe('CarouselComponent', () => {
  let component: MyComponent ;
  let fixture: ComponentFixture<MyComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ MyComponent ],
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(MyComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});
Run Code Online (Sandbox Code Playgroud)

谢谢!

unit-testing angular

28
推荐指数
5
解决办法
2万
查看次数

EF 包含 where 子句

我有资源和资源详细信息。MemberPoint 带有memberId 和ResourceId。

我想获取会员的资源详细信息。

在 SQL 中,

Select d.* From ResourceDetails d Inner Join 
        Resource on r d.ResourceId = r.Id Inner Join 
        MemberPoint mp on r.id = mp.ResourceId 
        where mp.memberId = 1
Run Code Online (Sandbox Code Playgroud)

在英孚,

   var query = _context.ResourceDetails
            .Include(d => d.Resource)
            .Include(r => r.Resource.Memberpoints)
            .Where(e => e.Resource.Memberpoints.Where(m => m.MemberId))
Run Code Online (Sandbox Code Playgroud)

当我写上面的 EF 查询时出现错误。

错误:System.Linq.IQueryable 的未知方法“Where(?)”

c# linq entity-framework

5
推荐指数
1
解决办法
9492
查看次数

更新.net Core 1.0到1.1后出错

我创建了新的asp.net核心web api项目并更新到1.1.我收到以下错误:

  1. 项目尚未还原或还原失败 - 运行dotnet restore WebApplication1 C:\ Program Files(x86)\ MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets

  2. 该项目未在"运行时"部分列出"win10-x64,win81-x64,win8-x64,win7-x64"之一.

  3. 您可能正在尝试发布不受支持的库.使用dotnet pack分发库.

无法找到与其中一个目标运行时兼容的框架'.NETCoreApp,Version = v1.0'的运行时目标:'win10-x64,win81-x64,win8-x64,win7-x64'.可能的原因:WebApplication1 C:\ Program Files(x86)\ MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets 262

请指教!

asp.net-core asp.net-core-1.1

5
推荐指数
1
解决办法
931
查看次数

如何在MVC5中从AccountController模拟ApplicationUserManager

我正在尝试在AccountController上编写Register Test for Register Method

我正在使用moq以及从Unit Test模拟ApplicationUserManager,ApplicationRoleManager和ApplicationSignInManager的正确方法是什么.

public AccountController(ApplicationUserManager userManager, ApplicationRoleManager roleManager, ApplicationSignInManager signInManager)
{
    UserManager = userManager;
    RoleManager = roleManager;
    SignInManager = signInManager;

}

public ApplicationUserManager UserManager
    {
        get
        {
            return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
        }
        private set
        {
            _userManager = value;
        }
    }

private ApplicationSignInManager _signInManager;
    public ApplicationSignInManager SignInManager
    {
        get
        {
            return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
        }
        private set { _signInManager = value; }
    }

private ApplicationRoleManager _roleManager;
    public ApplicationRoleManager RoleManager
    {
        get
        {
            return _roleManager ?? HttpContext.GetOwinContext().Get<ApplicationRoleManager>();
        } …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc unit-testing moq asp.net-mvc-5 asp.net-identity

4
推荐指数
1
解决办法
5695
查看次数

在ASP.Net Core 2.1 MVC中,TempData始终为空

我想在我的.net核心mvc应用程序中使用TempData。我遵循了https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/app-state?view=aspnetcore-2.1#tempdata上的文章

我总是得到NULL这是我的代码:

public async Task<ActionResult> Index(RentalsFilter filter)
{
    TempData["test"] = "ABC";
    return View();
}

public ActionResult Create()
{
    var abc = TempData["test"].ToString();
    return View();
}
Run Code Online (Sandbox Code Playgroud)

c# tempdata asp.net-core-2.0

4
推荐指数
2
解决办法
2547
查看次数