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
Install-Module -Name 'PSRule.Rules.Azure' -Force -Scope CurrentUser | |
Export-AzRuleData ` | |
-ResourceGroupName '<your-resource-group>' ` | |
-OutputPath 'out/templates/' | |
Assert-PSRule ` | |
-Module 'PSRule.Rules.Azure' ` | |
-InputPath 'out/templates/' ` | |
-o NUnit3 ` |
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
Describe 'Azure policies' { | |
foreach ($policy in $policies) { | |
It $policy.policyDefinitionReferenceId { | |
$definition = $definitions | where { $_.id -eq $item.policyDefinitionId } | |
$item.complianceState | Should -Be 'Compliant' -Because $definition.description | |
} | |
} | |
} |
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 Arcus.Testing; | |
string expected = "<root><child>100</child></root>"; | |
string actual = "<root><child>101</child></root>"; | |
AssertXml.Equal(expected, actual); | |
// Arcus.Testing.EqualAssertionException | |
// AssertXml.Equal failure: expected and actual XML documents do not match | |
// actual XML has a different value at /root/child/text(), expected 100 while actual 101 | |
// |
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 Arcus.Messaging.Abstractions.ServiceBus.MessageHandling; | |
using Arcus.Messaging.Pumps.Abstractions.Resiliency; | |
public class OrderMessageHandler : IAzureServiceBusMessageHandler<Order> | |
{ | |
private readonly IMessagePumpCircuitBreaker _circuitBreaker; | |
public OrderMessageHandler(IMessagePumpCircuitBreaker circuitBreaker) | |
{ | |
_circuitBreaker = circuitBreaker; |
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
// Guest -> GuestList -> ValidationResult<GuestList> | |
let add guest list = | |
Optic.map guests_ (fun gs -> g :: gs) | |
// Guest -> GuestList -> ValidationResult<GuestList> | |
let remove guest list = | |
Optic.get (guest_ guest.Name) list | |
>>= fun g -> Optic.map guests_ (List.except [g]) list |
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
let guests = GuestList.create [ | |
Guest.create "Eve" | |
Guest.create "Lisa" ] | |
let lens = guest_ >=> name_ "Eve" | |
// result : ValidationResult<GuestList> | |
let result = Optic.set lens "AdamEve" guests |
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
// A lens that provides the name of the guest. | |
let name_ : ResultLens<Guest, string> = | |
(fun g -> Ok g.Name), (fun n _ -> Guest.create n) | |
// A lens on the guest list that provides the individual guests on the list. | |
let guests_ : ResultLens<GuestList, Guest list> = | |
(fun (GuestList xs) -> Ok xs), fun xs _ -> GuestList.create xs | |
// A lens that points to a single guest on the guest list. | |
let guest_ name : ResultLens<GuestList, Guest> = |
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
type ValidationResult<'a> = Result<'a, ErrorsByTag> | |
type ResultLens<'a, 'b> = ('a -> ValidationResult<'b>) * ('b -> 'a -> ValidationResult<'a>) | |
module Compose = | |
type ResultLens = | |
| ResultLens with | |
static member (>=>) (ResultLens, (g2, s2) : ResultLens<'b, 'c>) = | |
fun ((g1, s1) : ResultLens<'a,'b>) -> | |
(fun a -> g1 a >>= fun b -> g2 b), | |
(fun c a -> g1 a >>= fun b -> s2 c b >>= fun b -> s1 b a) : ResultLens<'a,'c> |
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
open FPrimitive | |
type Guest = | |
private { Name : string } with | |
static member create name = result { | |
let! name = specModel id name { | |
notNullOrWhiteSpace "guest name should not be blank" | |
alphabetical "guest name should only contain alphabetical characters" } | |
return { Name = name } } |
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
[Fact] | |
public void Delete_WithMessageId_ShouldDeleteMessage() | |
{ | |
// Arrange | |
Message[] leftOverMessages = CreateMessages(); | |
Message targetMessage = CreateMessage(); | |
var repo = new InMemoryMessageRepository(leftOverMessages.Append(targetMessage)); | |
var service = CreateMessageService(repo); | |
// Act |
NewerOlder