public void MpxnEquality() { Mpxn.From(1234).Should().Be(Mpxn.From(1234)); (Mpxn.From(1234) == Mpxn.From(1234)).Should().BeTrue(); (Mpxn.From(1234) != Mpxn.From(1234)).Should().BeFalse(); Mpxn.From(1234).Should().Be(Mpxn.From("1234")); (Mpxn.From(1234) == Mpxn.From("1234")).Should().BeTrue(); (Mpxn.From(1234) != Mpxn.From("1234")).Should().BeFalse(); Mpxn.From(1234).Should().Be(1234); (Mpxn.From(1234) == 1234).Should().BeTrue(); (Mpxn.From(1234) != 1234).Should().BeFalse(); Mpxn.From(1234).Should().Be("1234"); (Mpxn.From(1234) == "1234").Should().BeTrue(); (Mpxn.From(1234) != "1234").Should().BeFalse(); Mpxn.From(1234).Should().NotBe(Mpxn.From(9999)); (Mpxn.From(1234) == Mpxn.From(9999)).Should().BeFalse(); (Mpxn.From(1234) != Mpxn.From(9999)).Should().BeTrue(); Mpxn.From(1234).Should().NotBe(Mpxn.From("9999")); (Mpxn.From(1234) == Mpxn.From("9999")).Should().BeFalse(); (Mpxn.From(1234) != Mpxn.From("9999")).Should().BeTrue(); Mpxn.From(1234).Should().NotBe(9999); (Mpxn.From(1234) == 9999).Should().BeFalse(); (Mpxn.From(1234) != 9999).Should().BeTrue(); Mpxn.From(1234).Should().NotBe("9999"); (Mpxn.From(1234) == "9999").Should().BeFalse(); (Mpxn.From(1234) != "9999").Should().BeTrue(); (Mpxn.From(1234) == (string)null).Should().BeFalse(); (Mpxn.From(1234) != (string)null).Should().BeTrue(); (Mpxn.From(1234) == (Mpxn)null).Should().BeFalse(); (Mpxn.From(1234) != (Mpxn)null).Should().BeTrue(); }
public void When_receving_a_reading_then_it_is_saved_against_the_meter() { var sut = new MeterReadingTakenFeature(); var meter = new Meter(Mpxn.From("1234")); sut.Handle(meter, 12.1m); meter.LatestReading().Should().Be(12.1m); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder .Entity <Meter>() .Property(e => e.Id) .HasConversion( v => v.ToString(), v => Mpxn.From(v)); modelBuilder.Entity <Reading>().Property <int>("Id"); }
public void When_receving_a_reading_then_MeterReadingSaved_is_published() { var publisher = Substitute.For <MessageContext>(); var sut = new MeterReadingTakenFeature(); sut.UseContext(publisher); var meter = new Meter(Mpxn.From(1234)); sut.Handle(meter, 12.1m); publisher.Received().Publish(Arg.Is <MeterReadingSaved>(x => x.Meter == "1234")); }
public bool TryFindById(Mpxn id, out Meter entity) { entity = Meters.FirstOrDefault(x => x.Id == id); return(entity != null); }
public Meter(Mpxn id) => Id = id;
public async Task Handle(MeterReadingTaken message, IMessageHandlerContext context) { var meter = aggregate.Load(Mpxn.From(message.Mpxn)); await feature.UseContext(context.Wrap()).Handle(meter, message.Reading); }