Skip to content

Instantly share code, notes, and snippets.

View TsuyoshiUshio's full-sized avatar
:octocat:
Enjoy coding

Tsuyoshi Ushio TsuyoshiUshio

:octocat:
Enjoy coding
  • Microsoft
  • Kirkland
View GitHub Profile
@TsuyoshiUshio
TsuyoshiUshio / local.settings.json
Created May 4, 2020 17:27
Distributed Tracing sample
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"APPINSIGHTS_INSTRUMENTATIONKEY": "<YOUR_APPINSGITHS_INSTRUMENTATIONKEY_HERE>"
}
}
@TsuyoshiUshio
TsuyoshiUshio / FunctionAppCorrelation.csproj
Created May 4, 2020 17:15
Distributed Tracing config
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RunAnalyzersDuringLiveAnalysis>true</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask.Telemetry" Version="2.2.0-alpha" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.5" />
@TsuyoshiUshio
TsuyoshiUshio / SampleTest.java
Created April 30, 2020 19:00
jMockit sample (Missing Invocation)
public class SampleTest {
@Test
public void executeSample(
@Mocked final TypedData data1,
@Mocked final TypedData data2
) throws Exception {
new Expectations() {{
data1.getName(); result = "foo";
data2.getName(); result = "bar";
}};
@TsuyoshiUshio
TsuyoshiUshio / SampleTest.java
Created April 30, 2020 18:54
jMockit sample
public class SampleTest {
@Test
public void executeSample(
@Mocked final TypedData data1,
@Mocked final TypedData data2
) throws Exception {
new Expectations() {{
data1.getName(); result = "foo";
data2.getName(); result = "bar";
}};
public class InvocationRequestTest {
@Mocked
private ParameterBinding binding;
@Test
public void test(@Mocked final Some some) throws Exception {
new Expectations() {{
binding.getName(); result = "ushio";
some.getName(); result = "mocked";
}
public final class ParameterBinding {
private ParameterBinding() {
}
public TypedData getData() {
return null;
}
public String getName() {
import org.junit.*;
import mockit.*;
import static org.junit.Assert.assertEquals;
public class InvocationRequestTest {
@Mocked
private ParameterBinding binding;
@Test
@TsuyoshiUshio
TsuyoshiUshio / database_test.go
Created April 4, 2020 00:22
Postgresql database testing.
ExpectedStatus := "success"
status := retry.DoWithRetry(t, "Waiting for DB connection validation...", 5, time.Duration(time.Second*5),
func() (string, error) {
output, err := k8s.RunKubectlAndGetOutputE(t, kubernetesOptions, "exec", psqlClientPodName, "--", "/bin/sh", "-c", fmt.Sprintf("PGPASSWORD=\"%s\" psql \"sslmode=require host=%s.postgres.database.azure.com dbname=%s user=%s@%s\";echo $?;", config.PGPassword, config.HostName, config.DBName, config.UserName, config.HostName))
if err != nil {
return "", err
}
t.Log("PostgresClient:", output)
if output == "0" {
@TsuyoshiUshio
TsuyoshiUshio / UnitTest.cs
Created March 20, 2020 04:31
Serial Prallel mixed tests
using System;
using System.Threading.Tasks;
using Xunit;
namespace SerialAndParallelSpike
{
[CollectionDefinition("Non-Parallel Collection", DisableParallelization = true)]
public class NonParallelCollectionDefinitionClass
{
}
@TsuyoshiUshio
TsuyoshiUshio / SerialParallel.cs
Created March 20, 2020 04:19
Serially exclusively
[CollectionDefinition("Non-Parallel Collection", DisableParallelization = true)]
public class NonParallelCollectionDefinitionClass
{
}
[Collection("Non-Parallel Collection")]
public class SerialTest
{
[Fact]
public async Task Test10()