Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

tests: add the first tests for ViewLocator

Aperta Adatta ai principianti
#341 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

Aggiungi un file di test in tests/LageBuch.Acceptance.Tests/ per src/LageBuch.App.Shared/ViewLocator.cs. Inizia leggendo ViewLocator.cs e NumericInputTests.cs, poi esegui make test PROJECT=tests/LageBuch.Acceptance.Tests FILTER=Name~ViewLocator. Copri il fallback null, il fallback in caso di vista mancante e le asserzioni Match; i test filtrati dovrebbero passare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

good first issue tests

src/LageBuch.App.Shared/ViewLocator.cs maps a view model to its view by string
convention: it replaces ViewModel with View in the type name and resolves
that type. Convention-based resolution breaks quietly when a file is renamed,
and there is no test file for it anywhere — the only mention in tests/ is a
passing comment in ForcesTabRenderTests.cs.

What to do

Add a new test file in tests/LageBuch.Acceptance.Tests/ (the only test project
that references LageBuch.App.Shared). Three cheap assertions cover the whole
class:

  1. Build(null) returns a TextBlock whose text is the em-dash placeholder.
  2. Build(x) for an ObservableObject subclass with no matching view returns a
    TextBlock starting with Nicht gefunden:.
  3. Match is true for a CommunityToolkit.Mvvm.ComponentModel.ObservableObject
    and false for a plain object.

The two fallback paths construct a TextBlock only, so a plain [Fact] is
enough and you do not need the Avalonia dispatcher. If you want to also assert
that a real view model resolves to its view, use [AvaloniaFact] and copy the
setup from NumericInputTests.cs in the same project.

Note this project is on xunit.v3 while the other test projects are on v2.

Verify
make test PROJECT=tests/LageBuch.Acceptance.Tests FILTER=Name~ViewLocator

Difficulty: easy.


New here?

Comment to claim this issue and it is yours. If no pull request appears within
seven days it goes back in the pool, no hard feelings.

Before you open the PR, please skim CONTRIBUTING.md:
commits need DCO sign-off (git commit -s) and a Conventional Commit subject.
Changes under src/ additionally need an entry under ## [Unreleased] in
CHANGELOG.md — CI fails the PR otherwise.

Questions are welcome right here or in
Discussions.

Lingua principale
C#
Stelle
1
Fork
3
Merge medio
4h 49m
PR unite (30g)
177

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeForFire/lagebuch

Tutte le issue di CodeForFire/lagebuch

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.