小编Dan*_*ega的帖子

JUnit测试预期异常的正确方法

大家好,我想知道这种测试我的异常的方式是否正常,我有这个例外我需要抛出第二个测试注释,我接收结果是一个红色的邪恶条,一个成功和一个失败,你可以猜到失败是我关心的,我有失败(); 但原因是因为我读到了测试异常的方法,现在我很困惑.

此外,我不得不说im willin得到绿色条,因为我期待异常,但我不知道失败是否是正确的方式来看到预期的异常的答案.

如果您有任何建议,我将不胜感激

@Before
    public void setUp() throws Exception {
        LogPack.logPacConfig(Constants.LOGGING_FILE);
        gtfri = "+RESP:GTFRI,380502,869606020101881,INCOFER-gv65,,10,1,1,0.0,0,888.1,-84.194560,9.955602,20170220074514,,,,,,0.0,,,,100,210100,,,,20170220074517,40A2$";
        weirdProtocol = "+RESP:GRI,380502,869606020101881,INCOFER-gv65,,10,1,1,0.0,0,888.1,-84.194560,9.955602,20170220074514,,,,,,0.0,,,,100,210100,,,,20170220074517,40A2$";
        factory = new LocomotiveFactory();
    }
    @Test
    public void GTFRICreationTester_shouldPass() throws TramaConProtolocoloDesconocido {
        assertTrue(factory.createLocomotive(gtfri, false, new Date()) instanceof LocomotiveGTFRI);
    }

    @Test(expected = TramaConProtolocoloDesconocido.class)
    public void GTFRICreationTester_shouldFail()  {
        try {
            factory.createLocomotive(weirdProtocol, false, new Date());
            fail("Expected an TramaConProtolocoloDesconocido");
        } catch (TramaConProtolocoloDesconocido e) {
            //assertSame("exception thrown as expected", "no se conoce el protocolo dado para la creacion de este factory", e.getMessage());;
        }
    }
Run Code Online (Sandbox Code Playgroud)

java junit unit-testing junit4

16
推荐指数
1
解决办法
2万
查看次数

dotnet core api 文件夹结构

我正在尝试启动一个新的 API。但有很多选项可以被认为是正确的。我只是想知道每个人都建议如何这样做,或者是否有一种我忽略的官方方法。这将是一个 N 层架构。具有控制器/BLL 类/DAL 层。以及一些与消息队列和其他服务进行通信的服务(我在同一解决方案中提取到不同的项目),但我的问题是对于主项目,你们将如何处理文件夹/命名空间。以及其中类的命名。这就是我愿意采取的方式,让我知道我们的想法:

apiproject
|
+> controllers/
|  + *Controller.cs (name of classes)
+> enumerables/
|  + *.cs (just a significant name)
+> handlers/
|  + I*Handler.cs (interfaces)
|  + implementors/
|  |  + *Handler.cs (implementations)
 +  Models/
|  +  *.cs (meaningfulName)
 +  DTO/
|  +  *.cs (meaningfulName)
 +  Validators/
|  +  *Validator.cs (DataAnnotations)
 +  Utils/
|  +  *Util.cs 
 +  Repositories/
|  +  I*Repository.cs 
|  + implementors/
|  |  + *Repository.cs (implementations)
|  + Entities/
|  | …
Run Code Online (Sandbox Code Playgroud)

c# api design-patterns directory-structure asp.net-core

3
推荐指数
1
解决办法
6104
查看次数