unit tests – Entity Framework and Domain Driven Design Testability

I use a DDD approach for domain classes. Although I have a problem with my design, that I manage it now but that I have not had a good idea to address it.

My architecture is as follows:

– Heart

  • Application(here i have a bunch of commands / queries which use domain entities and CQRS to handle use cases)
  • Field

-Services

-Infrastructure

-Presentation

My problem is based on the following. I have a class called template that implements the ITemplate interface. This interface implements several methods and properties. As we can see above

 public interface ITemplate
    {
        public int Id { get; set; }
        string Name { get; set; }

        string Definition { get; set; }

        ISource Source { get; set; }

        ITemplateDefinition GetTemplateDefinitionObject();

        void SetTemplateDefinition(string templateDefinitionString);
    }

Inside an order, placed on the Application folder, I have the following:

public async Task Handle(UpdateTemplateCommand request, CancellationToken cancellationToken)
        {
            var templateDto = request.Template;


            var sourceForTemplate = await SourceRepository.SingleAsync(x => x.Id == templateDto.SourceId);

            if (sourceForTemplate == null)
            {
                throw new NotFoundException(nameof(Domain.Entities.Source), request.Template.SourceId);
            }

            var templateToUpdate = await TemplateRepository.SingleAsync(x => x.Id == templateDto.Id);

           if (templateToUpdate == null)
            {
                throw new NotFoundException(nameof(Domain.Entities.Template), request.Template.Id);
            }


            if (!string.IsNullOrEmpty(templateDto.Definition))
            {
                try
                {
                    **templateToUpdate.SetTemplateDefinition(templateDto.Definition);**
                }
                catch (Exception e)
                {
                    throw e;
                }

            }

TemplateRepository.UpdateRFEntity ((Domain.Entities.Template) templateToUpdate);

The line with the surrounding ** is my problem.

When Unit tests this, I cannot simulate it because the repository returns a concrete implementation and not an interface, which, in my opinion, is the right way, because when it comes to an ORM like EF, with the ability to track entities and other mechanisms, we shouldn't let go of that by mapping responses to an interface.

Does anyone have any idea how to make it cleaner so you can make fun of class calls without needing to make the members virtual, because i already have an interface, and without having to transpose all responses to the interface?

dnd 5th – What aspects of a framework are official?

Based on this question, is Matt Mercer's homebrew frame now considered an official frame? what parts of an official framework? Is it only what is included in the official book? Is all the knowledge linked to the different official parameter books? If the author is writing a new book that is not officially published, is it official for the tradition?

It seems to me that only officially published books would be official and nothing else. If all of the associated knowledge is considered official for the framework, then books like the Dresden files are official, as are all of the hundreds of other books.

So what is official regarding the settings?

How to implement this ACL architecture in NodeJs using mongoose and the ExpressJs framework?

How can I implement this file so that it works with an express intermediary that can prevent a database user from accessing the methods of the routes specified by the acessByRole object?

  const accessByRole = {
        admin: {
            get: ['/api/country'],
            post: ['/api/country'],
            put: ['/api/country'],
            delete: ['/api/country']
        },
        user: {
            get: ['/api/country'],
            post: ['/api/another-route']
        }
    };

programming languages ​​- How can you cook a GUI framework inside an interpreter without freezing the interpreter?

I am writing a bytecode interpreter in C for a simple programming language.

I want to add GUI capabilities to the language. At first, I decided to create in the interpreter a wrapper for the GTK library. It is exposed to user code as an integrated module.

My problem is that GTK works by taking control of the thread: once you call g_application_run, the thread enters an endless listening loop inside GTK.

Why is this a problem? Because while we are "stuck" in this GTK loop, the interpreter bytecode interpretation loop is frozen. Bytecode Psuedo to demonstrate:

0 SOME OPCODE
1 SOME OTHER OPCODE
2 OPCODE INVOKING GTK WRAPPER FUNCTION <-- GTK invoked in C level and enters an endless loop
3 MORE OPCODES  <-------- This is never executed

My first thought to combat this was to design my GTK wrapper in a "close to 1: 1" style the way the C library is supposed to be used. For example in the pseudo code:

import gtk
func app_code() {
    # ... app code ...
}
gtk.application_run(app_code)

This supposedly solves the problem - we don't care about never leaving the GTK endless loop inside g_application_run, because it is now up to him to invoke our own user code.

The reason it won't work: the way user functions are called inside the interpreter, is by

  1. Push a new stack frame onto the call stack
  2. Setting the instruction pointer to point to the start of the bytecode of the called functions
  3. In the next iteration of the bytecode interpretation loop, the new function will naturally start to execute

The GTK wrapper can easily perform steps 1 and 2. But - step 3 will never happen because we are stuck in the GTK infinite loop. The interpreter loop never starts a new iteration.

My question is therefore: what are the possible options for solving this problem? And what are some examples of how this issue is addressed in existing projects?

  • Start the GTK loop on a different level C thread?
  • Ditch GTK and look for a less "framework-y" and more "library-y" GUI toolkit that doesn't take control of threads?
  • Any other options?

php – I'm having problems with the slim 2.0 framework

I am taking a course and developing an e-commerce project, I would like to know why the error below

get('/admin', function() {

    User::verifyLogin();

    $page = new PageAdmin();

    $page->setTpl("index");
});

$app->get('/admin/login', function() {

    $page = new PageAdmin((
        "header"=>false,
        "footer"=>false
    ));

    $page->setTpl("login");
});

$app->post('/admin/login', function() {

    User::login($_POST("login"), $_POST("password"));

    header("Location: /admin");
    exit;
});

$app->get('/admin/logout', function() {

    User::logout();
    header("Location: /admin/login");
    exit;
});

$app->get("/admin/forgot", function() {

    $page = new PageAdmin((
        "header"=>false,
        "footer"=>false
    ));

    $page->setTpl("forgot");

});

$app->post("/admin/forgot", function() {

    $user = User::getForgot($_POST("email"));

    header("Location: /admin/forgot/sent");
    exit;
});

$app->get("/admin/forgot/sent", function() {

    $page = new PageAdmin((
        "header"=>false,
        "footer"=>false
    ));

    $page->setTpl("forgot-sent");
});

$app->get("/admin/forgot/reset", function() {

    $user = User::validForgotDecrypt($_GET("code"));

    $page = new PageAdmin((
        "header"=>false,
        "footer"=>false
    ));

    $page->setTpl("forgot-reset", array(
        "name"=>$user("desperson"),
        "code"=>$_GET("code")
    ));
});

$app->post("/admin/forgot/reset", function() {

    $forgot = User::validForgotDecrypt($_POST("code"));

    User::setForgotUsed($forgot("idrecovery"));

    $user = new User();

    $password = password_hash($_POST("password"), PASSWORD_DEFAULT, (
        "cost"=>12
    ));

    $user->get((int)$forgot("iduser"));

    $user->setPassword($password);

    $page = new PageAdmin((
        "header"=>false,
        "footer"=>false
    ));

    $page->setTpl("forgot-reset-success");
});

 ?>
   config('debug', true);

require_once("site.php");

require_once("admin.php");

require_once("admin-users.php");

require_once("admin-categories.php");

require_once("admin-products.php");

$app->run();

 ?>

web development – Best framework for plugin architecture

My friends and I are looking to create a front end GUI application which is basically just a framework for hosting several other tools that can connect to it. Think VS Code, but instead of an IDE, each individual application plugged into it supports the GUI and presents its own data. The user can download several of these applications, each connects to the frame and uses the common presentation as its own graphical interface. I hope this makes sense?

It sounds rigid, but that's exactly what we need, we have a million little tools that are all different and must be common to make it easier to use.

However, we are all low level developers with little web development experience. I'm looking for the best way to do this because of course we want a nice, flashy, web-based, portable, future-proof interface blah blah more buzzwords, with the ability to Mobile use and cloud storage!

Right now, we are of course considering Electron, and we have used QT in the past, but are there any other technologies of which we should be aware that would work very well for this? The office PWAs look promising but not yet fully developed …

Is something like this "easy" to do with Electron?

Thank you for your help!

performance – Do variables really increase memory usage (.NET Framework / Core)?

Think of this simple example:

var testString = "some,text"
var stringSplit = testString.Split(',');
var newString = stringSplit(0) + " " + stringSplit(1)

Console.Write(newString)

Does the following example use less memory because it creates fewer variables?

var testString = "some,text"

Console.Write(testString.Split(',')(0) + " " + testString.Split(',')(1))

Also, does the second example work less well because it has to do the .Split twice?

I understand that the differences are so small that they could be ignored, I just want to understand the principle.

Entity Framework Core Migration Constructor not found

When you try to migrate to the nuget package manager console

I get the following error:

Construtor não encontrado no tipo 'Microsoft.EntityFrameworkCore.Design.OperationExecutor'.

I have the most recent versions provided by the nuget (3.1.2).

Has anyone had this problem, and if so, how did you solve it?
I have searched the internet, and there is very little information to help me.

entity framework – Returning multiple list data inside an object in the ASP dotnet Core API

I have this consignment entity model.

public Guid Id { get; set; }
public DateTime? DateCreated { get; set; }
public DateTime? DateModified { get; set; }
public bool? Deleted { get; set; }
public string Status { get; set; }
public string Services { get; set; }
public string CustomerReference { get; set; }
public string ConsignmentNote { get; set; }
public int? TotalPieces { get; set; }
...
public virtual ICollection ConsignmentDocument { get; set; }
public virtual ICollection ConsignmentLine { get; set; }
public virtual ICollection Legging { get; set; }

Now, the problem I face when returning all shipments is that I don't get any data from ConsignmentLine, Legging, ConsignmentDocument in the body of the response. I tested it with only ConsignmentLine first in my consignment controller. This is my GetAll () controller method.

// GET: api/Consignments
    (HttpGet)
    public async Task>> GetConsignment()
    {
        var consignment = await _context.Consignment
            .Include(conline => conline.ConsignmentLine.Where(cl => cl.Id == cl.Consignment.Id))
            .ToListAsync();
        return consignment;
    }

I am testing it from Postman and it returns Lamba Expression is not valid. What then should be the expression?

stochastic processes – Classification of stopping times in a Poisson process framework

Due to the general theory of stochastic processes of Dellacherie and Meyer, we know that dividing all downtime into an accessible and totally inaccessible part, i.e.

$ T = T_I corner T_A $ sure $ {T < infty } $ and with $ I, A in F_ {T -} $.

If we consider a Poisson process $ N $ in its natural filtration $ mathcal {F} ^ N $, I was wondering if we could prove that

$ Delta N_ {T_I} = 1 $ and $ Delta N_ {T_A} = 0 $ almost surely for everyone $ mathcal {F} ^ N $– downtime $ T $?

Or in other words (jump times are completely inaccessible by Meyer's theorem) don't we have that jump times are the only inaccessible?

Thank you very much for the ideas on how to prove this or a counter example.