unit testing in Typo3. What is the procedure to do it? - typo3-8.x

I have one question. In any custom extension folder, there is another folder called Tests.
My question is, how can I utilise it inorder to do unit test of each public function of controller and Repository?
What is the procedure to do it?
Can anyone help me?

If you want to start writing Unit Test for TYPO3 you should take a look at the official site from TYPO3 (https://wiki.typo3.org/Unit_Testing_TYPO3).
Or read the handout from Oliver Klee (https://github.com/oliverklee/tdd-reader) for an easy entry with his tea example (https://github.com/oliverklee/tea).

Related

I want to generate boiler plate code in my repository pattern project

As title suggests, I am creating open source project that is in .net core 2.0. here is the architecture of it.
Now, it's working fine with everything including code first, seeders, swagger UI, TDD etc.
But there are many places where I have to add/modify classes when I want to add new Table in Database (see SimpleCRUD.Model > Entities)
So, I think I can reduce that boilerplate code, but I am not sure what is best way to do it.
What I did so far?
I tried to create a windows app, which will check and generate code for new added entity.
What I am trying to achieve?
Is there anyway I can add some kind of code in my current project and that will check after each build? is it feasible? any other suggestion to make it working perfectly?
Reference
I have checked this working in few other frameworks like serenity, asp.net boilerplate etc.
T4 temples can help cut down the boiler plate...
https://dotnetthoughts.net/generate-your-database-entities-using-t4-templates/
You've asked for my help here
I agree with other posters that you might want to look into T4. It sounds like you also want to create an MSBuild task.
I outlined the steps to do this for a different question in post here
You can find my code generators under this folder, CodeGen.SessionProxies
The t4 example can be found here: AppSessionPartials.tt
The MSBuild task can be found here: GenerateSessionProxies.cs
I had it generating a nuget file through the CodeGen.SessionProxies.nuspec. You won't find it on nuget.com; I had a local nuget repository. It would be helpful to you to look at the corresponding install.ps1 to understand how to set the generator up as a msbuild task.
Disclaimer: All of the GitHub links are subject to break if I ever decide to clean up that repo.
Cheers

simple example for the creation of a custom directory namer

I have read the main idea of how Create a custom directory namer on github. But, I did not manage to know how to start. So, I am wondering if there is simple example for it.
Thank you very much.
You can find a sample DirectoryNamer here:https://github.com/dustin10/VichUploaderBundle/issues/242#issuecomment-44566041

s#arp architecture + command and handler

This is my first time using S#arp Architecture 2.0 in a project.
There is two folders in tasks project : Commands and CommandHandlers.
I shearch about it and tried to undestand by the cookbook project what do i have to put there. I am imagining that i have to do something like it was before: a "viewToModel" function and a SaveOrUpdate in the IRepository.
Somebody can explain the "Commands and CommandHandlers" or/and give me a good documentation about it?
Thanks a lot!
Have you seen the Cookbook wiki? Using commands?
From your questions, I understand you are after some sort of CRUD functionality, in which case going for a command and handler approach might be overkill, just load the entity in your controller, copy values from the form and save it. Using commands is more suited for a Task based UI and where there is some behavior you want on the entities.

Using an abstract data entity model with MVC3

I want to be able to share the same EDMX across multiple projects in the same solution. So I put it in its own project so that I can reference it. The problem is that when I try to use the Controller generator in MVC3 it won't let me because the EDMX is not under the Model folder. There has to be a simple way to fix this. Any ideas?
Thank you,
Aaron
Yep its really easy (when you know how). There is a complete walkthrough here http://thedatafarm.com/blog/data-access/mvc3-1-scaffolding-magic-with-database-or-model-first-not-just-code-first/ from Julie Lerman.
In brief when you scaffold the controller you need to specify both the model and the context from your separate project to get it to work.

Proper way to build a data Repository in ASP.NET MVC

I'm working on using the Repository methodology in my App and I have a very fundamental question.
When I build my Model, I have a Data.dbml file and then I'm putting my Repositories in the same folder with it.... IE:
Data.dbml
IUserRepository.cs
UserRepository.cs
My question is simple. Is it better to build the folder structure like that above, or is it ok to simply put my Interface in with the UserRepository.cs?
Data.dbml
UserRepository.cs which contains both the interface and the class
Just looking for "best practices" here. Thanks in advance.
General best practice is to have one class or one interface per file.
Here's the more generic discussion, which I think applies to your case:
One class per file rule in .NET?
As a developer new to your project, I would appreciate knowing that IUserRepository exists--without having to fish through your UserRepository.cs file.
Do whatever makes sense to you.
Personally I find browsing solutions for anything painful so I have hot keyed Goto Definition/Implementation and Resharpers FindUsages Go to Type, Go to File so I never have to click anything.
Combining interfaces and classes in one file makes sense if the class or interfaces are small.
Also if your following the Liskov substitution principal / a dependency injection strategy and general good design practices you would rarely be interacting with actual implementations anyway. Repositories should almost never be referred to by their concrete implementation.

Resources