Skip to content

Instantly share code, notes, and snippets.

View igas_app_svc_init.ps1
#####################
## EXERCISE 2
#####################
# Authenticate to Azure
Connect-AzAccount
# List the subscriptions your account has access to
Get-AzSubscription
View ForEachCosmosPartition.cs
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Documents.Linq;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
View Cosmos StoredProcedure
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace CosmosCreateSproc
{
class Program
{
static async Task Main(string[] args)
{
View StockTest
[TestMethod]
public void BuyWhenLastTradeWasSell_Test()
{
#region setup the stock service
decimal simulatedCurrentPrice = 8.03m;
Trade simulatedLastTrade = new Trade
{
Ticker = "ABC",
Side = "sell",
View StocksLogic
using Service;
using System;
namespace Business
{
public class StocksLogic
{
private readonly IStockService _stockService;
private readonly ILogService _logService;
View ILogService
namespace Service
{
public interface ILogService
{
void Log(string logMessage);
}
}
View IStockService
namespace Service
{
public interface IStockService
{
Trade Buy(string ticker, decimal nbrShares);
decimal GetCurrentPrice(string ticker);
Trade GetLastTrade(string ticker);
Trade Sell(string ticker, decimal nbrShares);
}
}
View StockServiceMocks
using Moq;
using Service;
using System;
namespace Business.Tests
{
public static class StockServiceMocks
{
/// <summary>
/// Causes GetCurrentPrice to return a specific price or optionally throws an exception.
@crowcoder
crowcoder / CSharpBasicAlternateDataStream
Last active Aug 13, 2019
A bare-bones example of how to write alternate data streams with C#
View CSharpBasicAlternateDataStream
using Microsoft.Win32.SafeHandles;
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace AlternateDataStreams
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
View usp_Output_No_Default
CREATE PROCEDURE [dbo].[usp_Output_No_Default]
@param1 VARCHAR(50) OUTPUT
AS
SELECT @param1;
SET @param1 = 'changed by procedure';
RETURN 0