This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.AspNetCore.Mvc.Filters; | |
namespace aspnetcore_filter.Filters | |
{ | |
public class ResultFilterSampleAttribute : ResultFilterAttribute | |
{ | |
override public void OnResultExecuting(ResultExecutingContext context) | |
{ | |
context.HttpContext.Response.Headers.Add("Author", "Aykut Asil"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.Configure<CookiePolicyOptions>(options => | |
{ | |
// This lambda determines whether user consent for non-essential cookies is needed for a given request. | |
options.CheckConsentNeeded = context => true; | |
options.MinimumSameSitePolicy = SameSiteMode.None; | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Home/Error"); | |
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Home/Error"); | |
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActivityController controller = Robolectric.buildActivity(MyAwesomeActivity.class).create().start(); | |
Activity activity = controller.get(); | |
// assert that something hasn't happened | |
activityController.resume(); | |
// assert it happened! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val okHttpClient = OkHttpClient.Builder() | |
.connectTimeout(2, TimeUnit.SECONDS) // For testing purposes | |
.readTimeout(2, TimeUnit.SECONDS) // For testing purposes | |
.writeTimeout(2, TimeUnit.SECONDS) | |
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
// ... | |
testOptions { | |
unitTests.returnDefaultValues = true | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Dispatcher dispatcher = new Dispatcher() { | |
@Override | |
public MockResponse dispatch(RecordedRequest request) throws InterruptedException { | |
if (request.getPath().equals("/v1/login/auth/")){ | |
return new MockResponse().setResponseCode(200); | |
} else if (request.getPath().equals("v1/check/version/")){ | |
return new MockResponse().setResponseCode(200).setBody("version=9"); | |
} else if (request.getPath().equals("/v1/profile/info")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val mockServer = MockWebServer() | |
mockServer.start() | |
val mockedResponse = MockResponse() | |
mockedResponse.setResponseCode(200) | |
mockedResponse.setBody("{}") // sample JSON | |
mockServer.enqueue(mockedReponse) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(JUnit4::class) | |
class BlogRepositoryUTest { | |
lateinit var blogRepository : BlogRepository | |
lateinit var mockServer : MockWebServer | |
lateinit var blogService : BlogService | |
@Before @Throws fun setUp() { | |
// Initialize mock webserver | |
mockServer = MockWebServer() |