teleren/devto huggingface dataset:
Introduction to ASP.NET Core Integration Testing
Tags: csharp, aspnetcore, testing, dotnet
Published: 2019-09-10 12:46:55

---
title: Introduction to ASP.NET Core Integration Testing
published: true
description: In this post I'll give you a quick introduction into how you can test your ASP.NET Core Controllers.
tags: csharp, asp.net core, testing, dotnet
series: ASP.NET Core Integration Testing
---
In this post I'll give you a quick introduction into how you can test your ASP.NET Core Controllers.

Please note that the term "Integration Testing" also covers other cases, such as testing data access or accessing the file system.

## Set up the project
A common guideline is to structure your ASP.NET Core projects in the following way:
```
.
├── src
│   └── MyProject.Api
│       └── Controllers
│           └── ValuesController
└── test
    ├── IntegrationTests
    │   └── MyProject.Api.Test
    │       └── ValuesControllerTest
    └── UnitTests
```

## Install the TestHost NuGet
Create a .NET Core Test project and then install the `Microsoft.AspNetCore.TestHost` package.
This package will provide options to configure the `TestServer`.

`> Install-Package Microsoft.AspNetCore.TestHost`

## Create the base class
Create a base class that our `ControllerTest` classes can inherit from. We will set up the `TestServer` and `HttpClient` used to perform requests.
```csharp
[TestClass]
public abstract class IntegrationTestInitializer
{
    protected HttpClient _client;

    [TestInitialize]
    public void Setup()
    {
        var builder = new WebHostBuilder()
            .UseStartup<Startup>();
        var server = new TestServer(builder);

        _client = server.CreateClient();
    }
}
```

## Create a `ControllerTest`

Let's pretend the Controller we want to test looks like this
```csharp
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
    // GET api/values
    [HttpGet]
    public ActionResult<IEnumerable<string>> Get()
    {
        return new string[] { "value1", "value2" };
    }
}
```

With the base class set up, we can then simply inherit from the base class and use our `_client` to perform requests against the API.
```csharp
[TestClass]
public class ValuesControllerTest : IntegrationTestInitializer
{
    [TestMethod]
    public async Task CanGetValues()
    {
        List<string> expectedResponse = new List<string> { "value1", "value2" };

        var responseJson = await _client.GetStringAsync("api/values");
        List<string> actualResponse = JsonConvert.DeserializeObject<List<string>>(responseJson);

        Assert.AreEqual(expectedResponse.Count, actualResponse.Count);
        foreach(var expectedValue in expectedResponse)
        {
            Assert.IsTrue(actualResponse.Contains(expectedValue));
        }
    }
}
```

This post described how you can integration test a very basic ASP.NET Core API.

In the real world you'll probably have a database behind the API that must be accessed and some endpoints may also be protected by an API-Key or JWT.
This post however should only serve as a quick introduction into integration testing.

{% github kai-oswald/IntegrationTestSample %}
How can I opening Network Drives with fs.readdir?
Tags: node, javascript, electronjs, filesystem
Published: 2019-09-10 12:07:19

---
title: How can I opening Network Drives with fs.readdir?
published: true
description: Hi everyone! I struggle this problem I can't open network derives in node application. I open local drives but network drives I can't open.
tags: nodejs, javascript, electronjs, file system
---

Hi everyone! I struggle this problem I can't open network derives in node application. I open local drives but network drives I can't open.
Extend console's methods without losing line information
Tags: javascript, webdev, tutorial
Published: 2019-09-10 11:58:20

Get ready for the most needlessly precise and niche post of this website as today we're learning how to add a **colored chip in front of your browser's console logs**!

Extending console's log, error, warn or other methods can be very useful to easily add some information or context to each log, especially using [CSS styling](https://developers.google.com/web/tools/chrome-devtools/console/console-write#styling_console_output_with_css)!

There's lots of ways we can use that but in this example we'll focus on how to easily identify logs coming from a library.

You'll need to actually replace the method by a new one, I recommend doing so in your app entry point (`index.js` in my case)

```js
const stylesWarning = [
    'background: #FFC82C',
    'border-radius: 3px',
    'color: white',
    'font-weight: bold',
    'padding: 2px 5px'
].join(';')

const _warn = console.warn;

console.warn = function(warnMessage) {
  console.group("%cMyLibrary", stylesWarning)
  _warn.apply(console, arguments)
  console.groupEnd()
}
```

You can then use the method as you would usually :

![Console.warn call](https://thepracticaldev.s3.amazonaws.com/i/zjsudexvlz2ayxwdf8zn.png)

Which will result in this :

![Console.warn result](https://thepracticaldev.s3.amazonaws.com/i/lix80ibqg3y9w682eky7.png)

Convenient and pretty!

There's one problem though: **the log's file and line number doesn't represent our original log but where our method was rewritten.** (`index.js` instead of `App.jsx` in this case) Not that convenient.

Thankfully, there's a trick around that one: instead of replacing it with a new function, you need to **modify the log method itself and return it.** (Thank you [StackOverflow's kylehuff](https://stackoverflow.com/a/26078207/6208520)!)

```js
console.warn = function() {
  return Function.prototype.bind.call(_warn, console, "%cMyLibrary", stylesWarning);
}();
```

Which will result in something similar to the previous one (I actually find it prettier) except for the line number showing the actual file and line number.

![Console.warn result](https://thepracticaldev.s3.amazonaws.com/i/45t3braftfwyzphvsemy.png)

If you or anyone in your team use VSCode's debugger, there's a little trick : CSS styles aren't reset between each argument so you'll need to add a second "%c" and a meaningless CSS rule string if you don't want your whole line colored, like so:

```js
console.warn = function() {
  return Function.prototype.bind.call(_warn, console, "%cMyLibrary%c", stylesWarning, 'color: inherit');
}();
```

The result is pretty useful and you won't have to change any of your console calls. If you can tough, **I recommend writing your own logger helper without mutating the console object**, it'll be less risky but you'll have to refactor a lot of code.

What do you think? Do you use this kind of tricks in your projects? Don't hesitate to comment!
Swift Minimal Coding Rules
Tags: swift, ios, codequality, codingstandards
Published: 2019-09-10 11:09:47

---
title: Swift Minimal Coding Rules
published: true
description: 
tags: swift,ios,codequality,codingstandards
---

# For whom is this?
- Entry level developers (or who works with them)
- Wants to code quickly but keep the minimum code quality
- Already introduced SwiftFormat and SwiftLint

You can find various coding rules, but many of them are long and might be overwhelming. This rule is simple enought to quickly start, easy to understand even for beginners.


# Rules
## Use Understandable Names
Naming is one of the most important points in code.
Take your time to think of naming.

## Segregate Classes from View Controllers
Don't put code unrelated to view into view controllers.
Don't put code unrelated to app status into AppDelegate.
Conform to Single Responsibility Principle.

## Separate Storyboards and View Controllers
In team development, you should avoid conflict.

## Put Common Code into Protocols
Don't Repeat Yourself.
Adopt Protocol Oriented Programming.
https://dev.to/noahkuwae/protocol-oriented-programming-pop-brief-summary-4i5b

## Put Common UI Parts into Xibs
Again, Don't Repeat Yourself.

## Conform to Cocoa MVC
This should be determined in each team, but MVC is basic and the most understandble architecture.

## Separate Classes (or Structs) by Extensions for each Protocol
This increases readability of the code.

Before: 
```swift
class SampleViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
	func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { ... }
	func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { ... }
	func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { ... }
...
}
```

After:
```swift
class SampleViewController: UIViewController { ... }

extension SampleViewController: UITableViewDataSource {
	func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { ... }
	func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { ... }
}

extension SampleViewController: UITableViewDelegate {
	func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { ... }
}
```

## Handle Errors
If you don't handle them now, add some comment like `// TODO`.

## Use assert or fatalError for Unexpected Cases
If you merely use `return`, you'll have difficulty in fixing it later.

## Split Your Code into Methods
If you want to write a comment for a chunk of code, it's a sign for creating a method.


# Reference
[15 Rules for Writing Quality Code | | InformIT](http://www.informit.com/articles/article.aspx?p=2223710)


# Note
This is subject to change, because currently I'm running a project using this rule (in 2019).
Some update might occur during the project.
Looking for a side project, which you could use yourself every day? Super Productivity needs your help!
Tags: help, angular
Published: 2019-09-10 11:08:28

---
title: Looking for a side project, which you could use yourself every day? Super Productivity needs your help!
published: true
description: I'm looking for people who would be willing to support me on my ongoing quest to make the app better every day.
tags: help, angular, opensource
cover_image: https://thepracticaldev.s3.amazonaws.com/i/8w8fg63vy3t0sjwwf9ja.jpg
---

I love [Super Productivity](https://github.com/johannesjo/super-productivity). It's my favorite side project and I use it every day to plan my tasks and to track my time. But my skill set and also my perspective after using it for over two years are limited.

You see, I'm resorting to cats. So this is serious!

I need your help!

## Things that would help

### Feedback
* What do you like and what not?
* What should be improved?
* What essential features are missing?
* If you don't, why won't you use the app?
* How do you use the app, if so? I need to figure in which direction to head, as there might be too many features at the moment.
* Reporting bugs

### Design & UX
I am not a designer. So there is probably a lot not to like. It would be absolutely great if a professional could have a look or two.
* Are the general concepts working? What should be improved?
* Providing better icons

### Features/Coding
* Implementing GitLab support
* Implementing support for private GitHub repositories
* Improved data syncing, 
  * syncing smaller chunks instead of the complete data
  * support to save the data to your own cloud storage (own cloud, Dropbox, etc.)
  * I am a fan of owning your data. The ideal would be to achieve a completely syncable [unhosted web app](https://unhosted.org/)

### Translations
* I ran the app through google translate. So there is at least one reason why they suck...
Weekly Cloud-Native Digest #11
Tags: weeklydigest, news, newsletter, cloud
Published: 2019-09-18 14:23:39

---
title: Weekly Cloud-Native Digest #11
published: true
tags: Weekly Digest,news,newsletter,cloud
canonical_url: https://educosta.dev/blog/weekly-cloud-native-digest-11/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/0ov6xhnzgga51ad9pkz7.jpg
---

Stay  up-to-date with what’s going on in cloud-native ecosystem. News,  tutorials and useful information on microservices, serverless,  containers, kubernetes and more.

-[Google Cloud Platform – Getting Started](https://www.jhanley.com/google-cloud-platform-getting-started/) 									
-[Serverless Antipatterns: What Not to Do With AWS Lambda?](https://www.simform.com/serverless-antipatterns/) 									
-[Progressive Delivery](https://www.infoq.com/presentations/progressive-delivery/) 									
-[The 3 Biggest Wins When Using Alpine as a Base Docker Image](https://nickjanetakis.com/blog/the-3-biggest-wins-when-using-alpine-as-a-base-docker-image) 									
-[Ten Things Serverless Architects Should Know](https://aws.amazon.com/pt/blogs/architecture/ten-things-serverless-architects-should-know/) 									
-[The 6 concepts you need to know before trying Serverless](https://www.thedevcoach.co.uk/the-6-serverless-concepts-you-need-to-know/) 									
-[Micro Frontends](https://martinfowler.com/articles/micro-frontends.html) 									
-[Monolith to Microservices to Serverless — Our journey](https://medium.com/responsetap-engineering/monolith-to-microservices-to-serverless-our-journey-745a2b9620ec) 									
-[Infrastructure as Code in the Era of GraphQL and Full Stack Serverless](https://dev.to/dabit3/infrastructure-as-code-in-the-era-of-graphql-and-full-stack-serverless-11bc) 									
-[Why Kubernetes will disappear](https://levelup.gitconnected.com/why-kubernetes-will-disappear-10ffcfb39f01) 	

The post [Weekly Cloud-Native Digest #11](https://educosta.dev/blog/weekly-cloud-native-digest-11/) appeared first on [Be Cloud Native](https://educosta.dev).  If you have any doubts or questions feel free to drop a comment here or reach me out on Twitter [@educostadev](http://twitter.com/educostadev).
HokuApps Robotization Stage improves Productivity for the Field Service Industry
Tags: hokuapps, fieldserviceindustry
Published: 2019-09-10 11:03:17

HokuApps Brings Technological Disruption in Field Service Industry

Hokuapps a Rapid Application Development (RAD) stage, disentangles the business procedure to help improve proficiency for organizations in the field administration industry. As an ever-increasing number of organizations go to computerized change to streamline their innovation, it is presently getting to be basic for the field service industry too to stroll down this way for simplicity of business.

As per a MarketsandMarkets report, the field service industry is going to see development to USD 5.9 billion by 2024 from the present size of USD 2.4 billion of every 2019.

To peruse more, visit REUTERS >> 
https://www.reuters.com/brandfeatures/venture-capital/article?id=133247

https://www.wfmj.com/story/41030775/hokuapps-automation-pillars-help-deploy-technology-solutions-in-weeks

https://www.einnews.com/pr_news/492207304/hokuapps-automation-platform-helps-improve-efficiency-for-the-field-service-industry
Advice: What language to learn for mobile dev?
Tags: help
Published: 2019-09-10 10:57:06

Hey guys,

I have an idea for an app that I would like to build, but I have no idea what language to learn to do it. I know iPhone is Swift, but would it be better to do it on Swift first, or learn it in something like Kotlin for Android and then create a Swift version later.

Not only that ideally this app would also be a website (which I could create using Oracle APEX as I already have a draft).

Any advice? I'm getting confused between all the many different options.
#discuss CRA CSS hot-reloading
Tags: discuss, react, createreactapp, css
Published: 2019-09-10 10:50:18

---
title: #discuss CRA CSS hot-reloading
published: true
description: The new CRA CSS hot-reloading issue.
tags: #discuss #react #create-react-app #css
---
Why does the latest version of create-react-app completely reload your application when you make a CSS edit as opposed to just applying the new style as it did in previous versions?
October 2019 Calendar 
Tags: printable
Published: 2019-09-10 10:34:24

An October schedule 2019 is the most ideal approach to arrange the day. It is essential to make an arrangement for the month before arriving. It helps all to remember the significant errands. In a schedule, occasions are likewise referenced. With this data, you can make an arrangement for your up and coming exercises. This makes our life additionally influencing in close to home or expert front. It is a superior answer to your issues. 

All things considered, we have just a single recommendation is that you should begin the October 2019 Printable Calendar and keep them before you. Since you can see every one of the things on schedule. Imprint significant dates in a specific segment. You will never miss any significant day of your life. There are numerous things we do in our life however individuals are occupied in day by day work and they lack the capacity to deal with doing the exercises. 

On the off chance that you need to invest energy with loved ones, messing around then for what reason would you say you are pausing? At that point start anticipating your day by day schedule. So you complete all the work on schedule and in an extra time you do every one of the things what you need you to do. It won't just be helping setting aside a few minutes however you will feel crisp and peaceful in your everyday schedule. Get the October 2019 Calendar layout in a different configuration. An alternate style is accessible in this article. You can spare them additionally take a printout. 

October is the tenth month of the year as indicated by the cutting edge schedule. It was the eight months in the Roman Calendar. There is wellbeing supervision which observes October as their national month. These incorporate solid lungs, bosom disease, lupus, spina bifida, visual impairment, and unexpected newborn child demise disorder (SIDS).
Don't use the br + br selector to hide the superfluous carriage return.
Tags: html, css, webdev
Published: 2019-09-10 10:26:32

You probably see some advice on the web and especially on Twitter about this selector:


```css
br + br {
  display: none;
}
```

Theorically, you want to hide the superfluous `<br>` elements that are sometime added by a text editor in a CMS when you hit Enter. This selector seem pretty neat! [This Tweet from Harry Robert](https://twitter.com/csswizardry/status/1170835532584235008) who got a lot of Retweets and Likes, mention this tip.

But do you know what is really happening…?

Let's give a look on [this Pen I made](https://codepen.io/yoanm/pen/ZEzrwre). It's a simple text with some carriage returns added on it. You will notice that I added two siblings `<br><br>` tag and this is the second one that we want to hide with this selector!

The fact is that the `<br>` tag is part of the text DOM, you will see that all the `<br>` tag except the first will be hiden. This will completely interfere with the reading by showing us some big parts of unreadable text.


I'm curious if you know others tips to get rid of bad outputs from CMS. Let me know!
How to know when CSS position sticky get's applied
Tags: css, javascript, webdev
Published: 2019-09-10 09:30:02

Often we require an element to have a position **sticky** when we scroll down the page. position: sticky can be thought as a combination of position: relative and position: fixed, an element remains in relative position until a point and then changes to fixed position.

```css
.sticky {
  position: -webkit-sticky;  /* for safari */
  position: sticky;
  top: 0px;
}
```
above element would be in position relative untill it's 0px from top , after that it changes to position:fixed. 

Prior to the sticky position, there was a JS solution to implement above behavior, which would require scroll event listener


###Support for position Sticky:

![Position-sticky](https://thepracticaldev.s3.amazonaws.com/i/kbdg7pwoto1z0px8087d.PNG)

IE and previous versions of Edge browsers do not support sticky position, it can be resolved using [stickyfill](https://github.com/wilddeer/stickyfill) polyfill.


###Know when an element gets sticky position :

CSS position sticky does not provide an event when the element gets the sticky position, there could be many use cases like changing style when element gets the sticky position, as a user scrolls the page, update a floating TOC widget to the current section, etc..

[Intersection Observation API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) is a Web API which helps to get callbacks fired when certain DOM elements “intersect” with one another. Intersection API asynchronously monitors the intersection of a target element with other elements which has a performance advantage over adding callbacks to the scroll events. IE has a [polyfill](https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver) for this API.
 
***
###Example :

{% codepen https://codepen.io/bhupendra1011/pen/GRKxWMM default-tab=js,result %}

 ☝ code shows that an element gets a fixed position on scrolling. When fixed, a CSS class is added to the element that changes its background color and updates icon. When sticky position is removed, the class is removed. 

***
Kabadian- Sinai | Valerie Jarrett's powerful advice for working mothers
Tags: kabadiansinai
Published: 2019-09-10 09:26:25

Valerie Jarrett became the longest-serving Senior Advisor to any U.S. President while working President Barack Obama's White House, and she made history after raising her daughter Laura as a single working mom.

On the latest episode of the second season of The Motherly Podcast, Sponsored by Prudential, Jarrett speaks with Motherly co-founder Liz Tenety about life, her new book, her work and why she wants working moms to be able to acknowledge their motherhood while in the workplace.

arrett made American history, but her story began when her parents chose to leave America.

"My father, who is a physician, was looking for a job in the mid-50s when he came out of the Army and he wanted to be at a major teaching institution doing research. And he couldn't find a job equivalent to what his white counterparts were making. So he and my mom who were adventuresome spirits no doubt, began to explore options outside of the United States and he landed a job offer to help start a brand new hospital in Shiraz, Iran," Jarrett explains.

She was the second baby to be born in that hospital and credits her early international experiences with providing her with a strong educational foundation and the ability to take professional risks and deviate from a linear career path.
Feedback on startup ideas
Tags: discuss, startup
Published: 2019-09-10 09:23:31

Hey all! Me and my business partner are throwing around ideas for a startup. We've come up with the following (links are to landing pages which explain the concept a little better):

* [Summarize & extract information](https://summarize.withcomb.com/) from Slack & email and send to people who should know about the info, e.g. C-levels, PMs, clients, etc. Reduces the number of mails you cc your boss into and ensures that valuable info isn't lost

* [Development work estimation multiplier](https://multiplier.withcomb.com/): Person A estimates work to be 1h, multiply by 3 for Person B, multiply by 0.75 for person C. Person X estimates, then multipliers are different.

* [Help non-technical project managers](https://non-technical.withcomb.com/) recognize issues & manage their team

* [Estimation-as-a-service](https://estimation.withcomb.com/): You give us the (development) work, we estimate how long it will take

* [Emotional status monitoring](https://emotions.withcomb.com/) & communication around organisation to improve efficiency of the team. Improve team emotional intelligence (EQ).



2 & 4 are related, yes. We're trying to see if there's any interest in any of these ideas. Your feedback would be great! Would you use any of these if they existed?

We also put together a [survey](https://forms.gle/BTvNdrmCWGgYyf4W6) if you like that sort of thing :)

Thank you so much for your time! Really appreciate it! If any of these turn into a reality, we'd love to give back by offering discounts/free periods/etc.